local extension = Package("zzz_fairy_observation")
extension.extensionName = "zenless__teyvat"
local U = require "packages/utility/utility"

Fk:loadTranslationTable{
    ["zzz_fairy_observation"] = "六分街仙灵观察",
    ["zzz"] = "绝区零",
    ["ysch4"] = "亦书成花",
  }

  local BelleWise = General(extension, "zzz__BelleWise", "Void", 3, 3, General.Bigender) 
  BelleWise.hidden = true
  local AstraYao = General(extension, "zzz__AstraYao", "qun", 3, 3, General.Female) 
  local Miyabi = General(extension, "zzz__Miyabi", "west", 4, 4, General.Female) 
  local Anby = General(extension, "zzz__Anby", "Void", 4, 4, General.Female) 
  Anby.hidden = true
  local Evelyn = General(extension, "zzz__Evelyn", "west", 4, 4, General.Female)
  local Corin = General(extension, "zzz__Corin", "west", 3, 3, General.Female)
  Corin.hidden = true
  local SilverAnby = General(extension, "zzz__SilverAnby", "Void", 4, 4, General.Female)
  local SoldierEleven = General(extension, "zzz__SoldierEleven", "Void", 4, 4, General.Female)
  SoldierEleven.hidden = true
  local Cuiji = General(extension, "zzz__Cuiji", "Void", 3, 5, General.Female)
  local Burnice = General(extension, "zzz__Burnice", "west", 3, 3, General.Female)
  local ZhuYuan = General(extension, "ysch4__ZhuYuan", "jin", 3, 3, General.Female)
  local Rina = General(extension, "ysch4__Rina", "liang", 4, 4, General.Female)
  Rina.hidden = true

  local zzz__RandomPlay = fk.CreateTriggerSkill{
    name = "zzz__RandomPlay",
    anim_type = "switch",
    events = {fk.AfterCardsMove},
    can_trigger = function(self, event, target, player, data)
      if player:hasSkill(self) then
        for _, move in ipairs(data) do
          if move.from and move.fromArea == Player.Judge and move.from == player.id then
            return true
          end
        end
      end
    end,
    on_use = function(self, event, target, player, data)
      local room = player.room
    end,
  
    on_acquire = function (self, player, is_start)
      local room = player.room
    end,
  }
  BelleWise:addSkill(zzz__RandomPlay)

  local zzz__RewindedLife = fk.CreateTriggerSkill{
    name = "zzz__RewindedLife",
    anim_type = "switch",
    events = {fk.AfterCardsMove},
    can_trigger = function(self, event, target, player, data)
      if player:hasSkill(self) then
        for _, move in ipairs(data) do
          if move.from and move.fromArea ~= Player.Judge and move.from == player.id then
            return true
          end
        end
      end
    end,
    on_use = function(self, event, target, player, data)
      local room = player.room
      player:drawCards(1, self.name)
    end,
  
    on_acquire = function (self, player, is_start)
      local room = player.room
    end,
  }
  BelleWise:addSkill(zzz__RewindedLife)

  Fk:loadTranslationTable{
    ["zzz__BelleWise"] = "铃·哲", 
    ["#zzz__BelleWise"] = "薪艾笠渡",
    ["cv:zzz__BelleWise"] = "侯小菲&林景",
    ["illustrator:zzz__BelleWise"] = "幽蝶化烬",
    ["designer:zzz__BelleWise"] = "幽蝶化烬",

    ["zzz__RandomPlay"] = "随机播放",
    [":zzz__RandomPlay"] = "每回合开始时，你可以令任意张手牌均视为本回合第一张被使用的单目标即时牌，这些牌不计入手牌上限且在本回合结束时弃置。",
    ["zzz__RewindedLife"] = "倒带暂停",
    [":zzz__RewindedLife"] = "你失去牌后，若比上次的牌数少，你可以分配弃牌堆中一张你失去的牌，再分配弃牌堆中一张牌名字数与上次牌数相同的牌。",

    ["~zzz__BelleWise"] = " …",
  }

-- 军令

--- 对某角色发起军令（抽取、选择、询问）
---@param from ServerPlayer @ 军令发起者
---@param to ServerPlayer @ 军令执行者
---@param skill_name string @ 技能名
---@param forced? boolean @ 是否强制执行
---@return boolean @ 是否执行
ZZZaskCommandTo = function(from, to, skill_name, forced)
  if from.dead or to.dead then return false end
  local room = from.room
  room:sendLog{
    type = "#AskCommandTo",
    from = from.id,
    to = {to.id},
    arg = skill_name,
    toast = true,
  }
  local index = ZZZstartCommand(from, skill_name)
  local invoke = ZZZdoCommand(to, skill_name, index, from, forced)
  return invoke
end

--- 军令发起者抽取并选择军令
---@param from ServerPlayer @ 军令发起者
---@param skill_name? string @ 技能名
---@param num? integer @ 抽取数量
---@return integer @ 选择的军令序号
ZZZstartCommand = function(from, skill_name, num)
  local allcommands = {"command1", "command2", "command3", "command4", "command5", "command6"}
  num = num or 2
  local commands = table.random(allcommands, num) ---@type string[]

  local room = from.room
  local choice = room:askForChoice(from, commands, "start_command", nil, true)

  room:sendLog{
    type = "#CommandChoice",
    from = from.id,
    arg = ":"+choice,
    toast = true,
  }
  return table.indexOf(allcommands, choice)
end

--- 询问军令执行者是否执行军令（执行效果也在这里）
---@param to ServerPlayer @ 军令执行者
---@param skill_name string @ 技能名
---@param index integer @ 军令序数
---@param from ServerPlayer @ 军令发起者
---@param forced? boolean @ 是否强制执行
---@return boolean @ 是否执行
ZZZdoCommand = function(to, skill_name, index, from, forced)
  if to.dead or from.dead then return false end
  local room = to.room

  local allcommands = {"command1", "command2", "command3", "command4", "command5", "command6"}

  local choice
  if not forced then
    choice = room:askForChoice(to, {allcommands[index], "Cancel"}, "do_command", nil, true)
  else
    choice = room:askForChoice(to, {allcommands[index]}, "do_command", nil, true, {allcommands[index], "Cancel"})
  end

  local result = choice == "Cancel" and "#commandselect_no" or "#commandselect_yes"
  room:sendLog{
    type = "#CommandChoice",
    from = to.id,
    arg = result,
    toast = true,
  }
  local commandData = {
    from = from,
    to = to,
    command = index,
  }
  if choice == "Cancel" then 
    room.logic:trigger("fk.AfterCommandUse", to, commandData)
    return false 
  end
  if room.logic:trigger("fk.ChooseDoCommand", to, commandData) then
    room.logic:trigger("fk.AfterCommandUse", to, commandData)
    return true
  end
  if index == 1 then
    local dest = room:askForChoosePlayers(from, table.map(room.alive_players, Util.IdMapper), 1, 1, "#command1-damage::" .. to.id, skill_name)[1]
    room:sendLog{
      type = "#Command1Damage",
      from = from.id,
      to = {dest},
    }
    room:doIndicate(from.id, {dest})
    room:damage{
      from = to,
      to = room:getPlayerById(dest),
      damage = 1,
      skillName = "command",
    }
  elseif index == 2 then
    to:drawCards(1, "command")
    if to == from or to:isNude() then return true end
    local cards = {}
    if #to:getCardIds{Player.Hand, Player.Equip} == 1 then
      cards = to:getCardIds{Player.Hand, Player.Equip}
    else
      cards = room:askForCard(to, 2, 2, true, "command", false, nil, "#command2-give::" .. from.id)
    end
    room:moveCardTo(cards, Player.Hand, from, fk.ReasonGive, "command", nil, false, from.id)
  elseif index == 3 then
    room:loseHp(to, 1, "command")
  elseif index == 4 then
    room:setPlayerMark(to, "@@command4_effect-turn", 1)
    room:addPlayerMark(to, MarkEnum.UncompulsoryInvalidity .. "-turn")
    room:handleAddLoseSkills(to, "#zzz_command4_prohibit", nil, false, true)
  elseif index == 5 then
    to:turnOver()
    room:setPlayerMark(to, "@@command5_effect-turn", 1)
    room:handleAddLoseSkills(to, "#zzz_command5_cannotrecover", nil, false, true)
  elseif index == 6 then
    if to:getHandcardNum() < 2 and #to:getCardIds(Player.Equip) < 2 then return true end
    local to_remain = {}
    if not to:isKongcheng() then
      table.insert(to_remain, to:getCardIds(Player.Hand)[1])
    end
    if #to:getCardIds(Player.Equip) > 0 then
      table.insert(to_remain, to:getCardIds(Player.Equip)[1])
    end
    local _, ret = room:askForUseActiveSkill(to, "#zzz_command6_select", "#command6-select", false)
    if ret then
      to_remain = ret.cards
    end
    local cards = table.filter(to:getCardIds{Player.Hand, Player.Equip}, function (id)
      return not (table.contains(to_remain, id) or to:prohibitDiscard(Fk:getCardById(id)))
    end)
    if #cards > 0 then
      room:throwCard(cards, "command", to)
    end
  end
  room.logic:trigger("fk.AfterCommandUse", to, commandData)
  return true
end

Fk:loadTranslationTable{
  ["command"] = "军令",

  ["#StartCommand"] = "%arg：请选择一项军令<br>%arg2；<br>%arg3",
  ["command1"] = "军令一",
  ["command2"] = "军令二",
  ["command3"] = "军令三",
  ["command4"] = "军令四",
  ["command5"] = "军令五",
  ["command6"] = "军令六",

  [":command1"] = "军令一：对发起者指定的角色造成1点伤害",
  [":command2"] = "军令二：摸一张牌，然后交给发起者两张牌",
  [":command3"] = "军令三：失去1点体力",
  [":command4"] = "军令四：本回合不能使用或打出手牌且所有非锁定技失效",
  [":command5"] = "军令五：叠置，本回合不能回复体力",
  [":command6"] = "军令六：选择一张手牌和一张装备区里的牌，弃置其余的牌",

  ["start_command"] = "发起军令",
  ["#AskCommandTo"] = "%from 发动了 “%arg”，对 %to 发起了 <font color='#0598BC'><b>军令",
  ["#CommandChoice"] = "%from 选择了 %arg",
  ["chose"] = "选择了",

  ["do_command"] = "执行军令",
  ["#commandselect_yes"] = "执行军令",
  ["#commandselect_no"] = "不执行军令",

  ["#command1-damage"] = "军令：请选择 %dest 伤害的目标",
  ["#Command1Damage"] = "%from 选择对 %to 造成伤害",
  ["#command2-give"] = "军令：请选择两张牌交给 %dest",
  ["@@command4_effect-turn"] = "军令禁出牌技能",
  ["@@command5_effect-turn"] = "军令 不能回血",
  ["#command6-select"] = "军令：请选择要保留的一张手牌和一张装备",
}

-- 军令四
local command4_prohibit = fk.CreateProhibitSkill{
  name = "#zzz_command4_prohibit",
  -- global = true,
  prohibit_use = function(self, player, card)
    if player:getMark("@@command4_effect-turn") > 0 then
      local subcards = card:isVirtual() and card.subcards or {card.id}
      return #subcards > 0 and table.every(subcards, function(id) return table.contains(player:getCardIds(Player.Hand), id) end)
    end
  end,
  prohibit_response = function(self, player, card)
    if player:getMark("@@command4_effect-turn") > 0 then
      local subcards = card:isVirtual() and card.subcards or {card.id}
      return #subcards > 0 and table.every(subcards, function(id) return table.contains(player:getCardIds(Player.Hand), id) end)
    end
  end,
}
Fk:addSkill(command4_prohibit)

-- 军令五 你不准回血！
local command5_cannotrecover = fk.CreateTriggerSkill{
  name = "#zzz_command5_cannotrecover",
  -- global = true,
  refresh_events = {fk.PreHpRecover},
  can_refresh = function(self, event, target, player, data)
    return target == player and player:getMark("@@command5_effect-turn") > 0
  end,
  on_refresh = function(self, event, target, player, data)
    data.num = 0
    return true
  end,
}
Fk:addSkill(command5_cannotrecover)

-- 军令六
local command6_select = fk.CreateActiveSkill{
  name = "#zzz_command6_select",
  can_use = Util.FalseFunc,
  target_num = 0,
  card_num = function()
    local x = 0
    if #Self.player_cards[Player.Hand] > 0 then x = x + 1 end
    if #Self.player_cards[Player.Equip] > 0 then x = x + 1 end
    return x
  end,
  card_filter = function(self, to_select, selected)
    if #selected == 1 then
      return (Fk:currentRoom():getCardArea(to_select) == Card.PlayerEquip) ~=
      (Fk:currentRoom():getCardArea(selected[1]) == Card.PlayerEquip)
    end
    return #selected == 0
  end,
}
Fk:addSkill(command6_select)
Fk:loadTranslationTable{
  ["#command6_select"] = "军令",
}

 --[[local yaoxing = fk.CreateTriggerSkill{
    name = "zzz__yaoxing",
    anim_type = "switch",
    frequency = Skill.Compulsory,
    events = {fk.GameStart, fk.EventLoseSkill},
    can_trigger = function (self, event, target, player, data)
      return (event == fk.GameStart and player:hasSkill(self)) or (event == fk.EventLoseSkill and target == player and data == self)
    end,
    on_use = function(self, event, target, player, data)
      local room = player.room
      if event == fk.GameStart then
        local skills = {}
        for i = 1, 2, 1 do
          local skill = "zzz"..i.."__jinpao","zzz"..i.."__shuwan"
          --local name = table.random(skill, 1)
          if not player:hasSkill(skill, true) then
            table.insert(skills, skill)
          end
          if #skills == 1 then break end
        end
        room:handleAddLoseSkills(player, skills, nil, true, false)
      else
      local x = 0
      for _, s in ipairs(player.player_skills) do
        if s:isPlayerSkill(player) and player:usedSkillTimes(s.name, Player.HistoryTurn) > 0 then
          x = x + 1
        end
      end
      if x > 0 then
       player:drawCards(x, self.name)
      end
      end
    end,
  }
  AstraYao:addSkill(yaoxing)

  ---@param skill string|Skill 
  local isPlayerSkill = function (skill) -- 原汤化原食，直接让元子攸助战了
    if type(skill) == "string" then
      skill = Fk.skills[skill]
    end
    skill = skill.main_skill or skill
    return skill.visible and not (skill.cardSkill or skill.name:endsWith("&") or skill.attached_equip or
    skill.global or skill == GameRule or skill == Fk.game_modes[Fk:currentRoom().settings.gameMode].rule)
  end

  local zhuanyin = fk.CreateTriggerSkill{
    name = "zzz__zhuanyin",
    anim_type = "swtich",
    switch_skill_name = "zzz__zhuanyin",
    events = {fk.SkillEffect},
    can_trigger = function(self, _, target, player, data)
      local room = player.room
      local currentEvent = room.logic:getCurrentEvent()
      local lastEvent = room.logic:getEventsByRule(GameEvent.SkillEffect, 1, function (e)
        return e.id < currentEvent.id and e.data[2] == player and isPlayerSkill(e.data[3])
      end, 1)[1]
      if lastEvent then
        local last = lastEvent.data[3]
        last = (last.main_skill or last)
        return player:hasSkill(self) and data ~= self and data.visible and target == player and player:hasSkill(data, true, true)
        and (player:getSwitchSkillState(self.name, false) == fk.SwitchYang and last == data or last ~= data)
      end
    end,
    on_cost = function(self, event, target, player, data)
      if player:getSwitchSkillState(self.name, false) == fk.SwitchYang then
        return true
      else
        return player.room:askForSkillInvoke(player, self.name, nil, "#zzz__zhuanyin-invoke")
      end
    end,
    on_use = function(self, _, target, player, data)
      local room = player.room
      if player:getSwitchSkillState(self.name, true) == fk.SwitchYang then
        room:setPlayerMark(player, "@@zhuanyin_nolimit", 1)
      else
        local skills = table.map(table.filter(player.player_skills, function (s)
            return s:isPlayerSkill(player) and s.visible
          end), Util.NameMapper)
          local skillToStr = function (list)
            return table.map(list, function (s)
              local skill = Fk.skills[s]
              if (skill.frequency == Skill.Limited or skill.frequency == Skill.Wake) and player:usedSkillTimes(s, Player.HistoryGame) > 0 then
                s = "SkillInvoked:::"..s
              end
              return s
            end)
          end
          local returnSkill = function (list)
            return table.map(list, function (s)
              if s:startsWith("SkillInvoked") then
                s = s:split(":::")[2]
              end
              return s
            end)
          end
          skills = skillToStr(skills)
          local tolose = {}
          tolose = room:askForChoices(player, skills, 0, 1, self.name, "#zzz__zhuanyin-lose", false)
          tolose = returnSkill(tolose)
          if #tolose > 0 then
            room:handleAddLoseSkills(player, "-"..table.concat(tolose, "|-"))
          else
            room:loseHp(player, 1, self.name)
        end
      end
    end,
  }
  AstraYao:addSkill(zhuanyin)
  ]] 

  --for loop = 0, 2, 1 do  --两个应该够用（限制繁殖数量）
  local jinpao = fk.CreateTriggerSkill{
    name = "zzz__jinpao", -- or "zzz"..loop.."__jinpao",
    anim_type = "offensive",
    events = {fk.CardUsing},
    can_trigger = function(self, event, target, player, data)
      return target == player and player:hasSkill(self) and
      data.extra_data and data.extra_data.combo_skill and data.extra_data.combo_skill[self.name]
    end,
    on_cost = function (self, event, target, player, data)
    local invoke = player.room:askForSkillInvoke(player, self.name, nil, "#zzz__jinpao-invoke")
    if invoke then
      return true
    else
      player.room:setPlayerMark(player, "@zzz__jinpao", 0)
      end
    end,
    on_use = function (self, event, target, player, data)
      local room = player.room
      room:setPlayerMark(player, "@zzz__jinpao", 0)
      local card = room:askForCard(player, 0, 999, true, self.name, false, ".", "#zzz__jinpao-ask")
      room:recastCard(card, player, self.name)
      local x = 0
        for _, id in ipairs(card) do
          if #Fk:getCardById(id, true):getAvailableTargets(player) == 0 then
            x = x + 1
          end
        end
      if x >= 2 and not player.dead then
        player:drawCards(1, self.name)
        if not player.dead then
          room:setPlayerMark(player, "@@zzz__jinpao-bydis", 1)
        end
      end
    end,

    refresh_events = {fk.PreCardUse, fk.CardUsing},
    can_refresh = function (self, event, target, player, data)
      --[[ local skills = {}
      for i = 1, 2, 1 do
        local skill = "zzz"..i.."__jinpao"
        if player:hasSkill(skill, true) then
        table.insert(skills, skill)
        end
      end ]] 
      if event == fk.PreCardUse then
        return target == player and player:getMark("@@zzz__jinpao-bydis") > 0
      elseif event == fk.CardUsing then
        return target == player and player:hasSkill(self, true) and data.card and ((type(data.tos) ~= "table") 
        or (#TargetGroup:getRealTargets(data.tos) > 0))
      end
    end,
    on_refresh = function (self, event, target, player, data)
      local room = player.room
      if event == fk.PreCardUse then
        room:setPlayerMark(player, "@@zzz__jinpao-bydis", 0)
      elseif event == fk.CardUsing then
        local targets = TargetGroup:getRealTargets(data.tos)
        local mark = player:getTableMark("@zzz__jinpao")
        local clear = true
        if type(data.tos) == "table" then
          for _, p in ipairs(targets) do
          if #mark == 0 and p ~= player.id and clear then
          room:addTableMark(player, "@zzz__jinpao", "√")
          clear = false
        elseif (#mark == 1 and not table.find(targets, function(pid) return pid ~= player.id end)) then
          room:addTableMark(player, "@zzz__jinpao", "√")
          clear = false
          end
          end
      elseif #mark == 1 and type(data.tos) ~= "table" then
          room:addTableMark(player, "@zzz__jinpao", "√")
          clear = false
        end
        if clear then
          room:setPlayerMark(player, "@zzz__jinpao", 0)
        end
        if #player:getTableMark("@zzz__jinpao") == 2 then
            data.extra_data = data.extra_data or {}
            data.extra_data.combo_skill = data.extra_data.combo_skill or {}
            data.extra_data.combo_skill[self.name] = true
        return
        end
      end
    end,

    on_lose = function (self, player, is_death)
      player.room:setPlayerMark(player, "@zzz__jinpao", 0)
    end,
  }
--[[if loop > 0 then
    Fk:addSkill(jinpao)
  else
    AstraYao:addSkill(jinpao)
  end
  Fk:loadTranslationTable{
    ["zzz"..loop.."__jinpao"] = "尽咆",
    [":zzz"..loop.."__jinpao"] = "连招技（目标含有其他角色+目标不含其他角色），你可以重铸任意张牌，若你手牌数等于两张连招牌的牌名字数，你视为使用【杀】。",
  }
end]]
  local jinpao_targetmod = fk.CreateTargetModSkill{
    name = "#zzz__jinpao_targetmod",
    bypass_distances =  function(self, player, skill, card, to)
      return card and player:getMark("@@zzz__jinpao-bydis") > 0
    end,
  }
  jinpao:addRelatedSkill(jinpao_targetmod)
  AstraYao:addSkill(jinpao)

  local shuwan = fk.CreateTriggerSkill{
    name = "zzz__shuwan",
    anim_type = "offensive",
    events = {fk.CardUsing},
    can_trigger = function(self, event, target, player, data)
      return target == player and player:hasSkill(self) and
      data.extra_data and data.extra_data.combo_skill and data.extra_data.combo_skill[self.name]
    end,
    on_cost = function (self, event, target, player, data)
    if #player:getCardIds("h") < 2 then
      player.room:setPlayerMark(player, "@zzz__shuwan", 0)
      return false
    else
    local to = player.room:askForChoosePlayers(player, table.map(table.filter(player.room:getAllPlayers(), function(p)
      return not p:isNude() end), Util.IdMapper), 1, 1, "#zzz__shuwan-choose", self.name, true)
      if #to > 0 then
        self.cost_data = to[1]
        return true
      else
        player.room:setPlayerMark(player, "@zzz__shuwan", 0)
        return false
      end
    end
    end,
    on_use = function (self, event, target, player, data)
      local room = player.room
      room:setPlayerMark(player, "@zzz__shuwan", 0)
      local to = room:getPlayerById(self.cost_data)
      local card = room:askForCard(player, 2, 2, false, self.name, false, ".", "#zzz__shuwan-card")
      player:showCards(card)
      if not player.dead and not to:isNude() then
        local chosen = room:askForCardChosen(player, to, "he", self.name)
        room:throwCard({chosen}, self.name, to, player)
        if to.dead then return end
        local list = {}
        local canuse = true
        if #Fk:getCardById(chosen, true):getAvailableTargets(to, {bypass_times = true}) > 0 and
         (table.contains(player:getCardIds("h"), chosen) or table.contains(room.discard_pile, chosen)) then
          table.insertIfNeed(list, chosen)
          else
          canuse = false
        end
        for _, id in ipairs(card) do
          if #Fk:getCardById(id, true):getAvailableTargets(to, {bypass_times = true}) > 0 and
          (table.contains(player:getCardIds("h"), id) or table.contains(room.discard_pile, id)) then
            table.insertIfNeed(list, id)
          else
            canuse = false
            break
          end
        end
        if #list < 1 or not canuse then return end
        local use = U.askForUseRealCard(room, to, list, nil, self.name, "#zzz__shuwan-use",
        {expand_pile = list, bypass_times = true}, true, false)
        if use then
          use = {
            card = use.card,
            from = to.id,
            tos = use.tos,
            extraUse = true
          }
          use.card.skillName = self.name
          room:useCard(use)
        end
      end
    end,

    refresh_events = {fk.CardUsing},
    can_refresh = function (self, event, target, player, data)
      return target == player and player:hasSkill(self, true) and data.card and ((type(data.tos) ~= "table") 
      or (#TargetGroup:getRealTargets(data.tos) > 0))
    end,
    on_refresh = function (self, event, target, player, data)
      local room = player.room
      local targets = TargetGroup:getRealTargets(data.tos)
      local mark = player:getTableMark("@zzz__shuwan")
      local clear = true
      if type(data.tos) == "table" then
        for _, p in ipairs(targets) do
          if #mark == 0 and player:distanceTo(room:getPlayerById(p)) <= 1 and clear then
          room:addTableMark(player, "@zzz__shuwan", "√")
          clear = false
          break
        elseif #mark == 1 and player:distanceTo(room:getPlayerById(p)) ~= 1 then
          room:addTableMark(player, "@zzz__shuwan", "√")
          clear = false
          break
          end
        end
    elseif #mark == 1 and type(data.tos) ~= "table" then
        room:addTableMark(player, "@zzz__shuwan", "√")
        clear = false
      end
      if clear then
        room:setPlayerMark(player, "@zzz__shuwan", 0)
      end
      if #player:getTableMark("@zzz__shuwan") == 2 then
          data.extra_data = data.extra_data or {}
          data.extra_data.combo_skill = data.extra_data.combo_skill or {}
          data.extra_data.combo_skill[self.name] = true
      return
      end
    end,

    on_lose = function (self, player, is_death)
      player.room:setPlayerMark(player, "@zzz__shuwan", 0)
    end,
  }
  AstraYao:addSkill(shuwan)

  Fk:loadTranslationTable{
    ["zzz__AstraYao"] = "耀嘉音", 
    ["#zzz__AstraYao"] = "千千阙歌",
    ["cv:zzz__AstraYao"] = "小N",
    ["illustrator:zzz__AstraYao"] = "mele_ck",
    ["designer:zzz__AstraYao"] = "幽蝶化烬",
  
    --["zzz__yaoxing"] = "耀星",
    --[":zzz__yaoxing"] = "锁定技，游戏开始时，你随机获得一个 “尽咆” 或 “抒婉”。你失去本技能时，摸你本回合发动过的技能数张牌。",
    --["zzz__zhuanyin"] = "转音",
    --[":zzz__zhuanyin"] = "转换技，你发动其他技能时，若与上一个：阳：相同，你下一张牌的目标可以为一名角色；阴：相同，你可以失去一个技能或1点体力。",

    ["zzz__jinpao"] = "尽咆",
    [":zzz__jinpao"] = "连招技（目标（含有+不含）其他角色），你可以重铸任意张牌，若至少两张不可使用，你摸一张牌，且你使用的下一张牌无距离限制。",
    ["zzz__shuwan"] = "抒婉",
    [":zzz__shuwan"] = "连招技（有目标与你距离（不大于1+不为1）），你可以展示两张手牌，弃置一名角色一张牌，若其能均使用这些牌，其使用其中一张。",

    --["@@xingzhuan_nolimit"] = "星转 任意目标",
    --["SkillInvoked"] = "(已发动)",
    ["@zzz__jinpao"] = "尽咆",
    ["@@zzz__jinpao-bydis"] = "尽咆 无视距离",
    ["#zzz__jinpao-invoke"] = "是否发动 尽咆？",
    ["#zzz__jinpao-ask"] = "请重铸任意张牌，若至少两张不可使用，你摸一张牌且使用下一张牌无距离限制。",
    ["@zzz__shuwan"] = "抒婉",
    ["#zzz__shuwan-choose"] = "抒婉：请选择一名角色，展示两张手牌并弃置其一张牌。",
    ["#zzz__shuwan-card"] = "抒婉：请展示两张手牌！",
    ["#zzz__shuwan-use"] = "抒婉：请使用其中的一张牌！",

    ["$zzz__xingzhuan"] = "就算是你，比赛我也不会放水！",
    ["$zzz__jinpao"] = "兔兔伯爵，出击！",
    ["$zzz__shuwan"] = "交给我吧！",
    ["~zzz__AstraYao"] = "这次我…输了啊…",
  }

  local shuangyue = fk.CreateTriggerSkill{
    name = "zzz__shuangyue",
    anim_type = "offensive",
    events = {fk.CardUsing},
    can_trigger = function(self, event, target, player, data)
      return target == player and player:hasSkill(self) and
      data.extra_data and data.extra_data.combo_skill and data.extra_data.combo_skill[self.name]
    end,
    on_cost = function (self, event, target, player, data)
    local invoke = player.room:askForSkillInvoke(player, self.name, nil)
    if invoke then
      return true
    else
        local room = player.room
        room:setPlayerMark(player, "@zzz__shuangyue", 0)
        room:setPlayerMark(player, "zzz__shuangyue-name", 0)
        room:setPlayerMark(player, "zzz__shuangyue-combo", 0)
      end
    end,
    on_use = function (self, event, target, player, data)
      local room = player.room
      local x , y = 0 , 0
      x = x + player:getMark("zzz__shuangyue-name")
      y = y + player:getMark("zzz__shuangyue-combo")
        room:setPlayerMark(player, "@zzz__shuangyue", 0)
        room:setPlayerMark(player, "zzz__shuangyue-name", 0)
        room:setPlayerMark(player, "zzz__shuangyue-combo", 0)
      local choices = {"#zzz__shuangyue-draw:::"..(y-2)}
      if player:usedSkillTimes(self.name, Player.HistoryRound) <= 1 then
        table.insert(choices, "draw3__instead")
      end
      local choice = room:askForChoice(player, choices, self.name, "#zzz__shuangyue-choice")
      if choice == "draw3__instead" then
      player:drawCards(3, self.name)
      elseif y - 2 > 0 then
      player:drawCards( y - 2 , self.name)
      end
    end,

    refresh_events = {fk.AfterCardUseDeclared},
    can_refresh = function (self, event, target, player, data)
      return target == player and player:hasSkill(self, true)
    end,
    on_refresh = function (self, event, target, player, data)
      local room = player.room
      local lens = Fk:translate(data.card.trueName, "zh_CN"):len()
      room:addPlayerMark(player, "zzz__shuangyue-name", lens)
      room:addPlayerMark(player, "zzz__shuangyue-combo", 1)
      local record = {""..player:getMark("zzz__shuangyue-name"), "进度:"..player:getMark("zzz__shuangyue-combo")}
      room:setPlayerMark(player, "@zzz__shuangyue", record)
      if player:getMark("zzz__shuangyue-name") > 6 then
        room:setPlayerMark(player, "@zzz__shuangyue", 0)
        room:setPlayerMark(player, "zzz__shuangyue-name", 0)
        room:setPlayerMark(player, "zzz__shuangyue-combo", 0)
      end
      if player:getMark("zzz__shuangyue-name") == 6 then
          data.extra_data = data.extra_data or {}
          data.extra_data.combo_skill = data.extra_data.combo_skill or {}
          data.extra_data.combo_skill[self.name] = true
      return
      end
    end,

    on_lose = function (self, player, is_death)
      local room = player.room
        room:setPlayerMark(player, "@zzz__shuangyue", 0)
        room:setPlayerMark(player, "zzz__shuangyue-name", 0)
        room:setPlayerMark(player, "zzz__shuangyue-combo", 0)
    end,
  }
  Miyabi:addSkill(shuangyue)

  local hanque = fk.CreateTriggerSkill{
    name = "zzz__hanque",
    anim_type = "defensive",
    events = {fk.AfterSkillEffect},
    can_trigger = function(self, _, target, player, data)
    if table.every(player.room:getOtherPlayers(player, false), function(p)
      return player:getHandcardNum() > p:getHandcardNum() end) then return false end
      local cards = table.filter(player:getCardIds("h"), function (id)
        return Fk:getCardById(id):getMark("@@zzz__hanque-inhand") == 0
      end)
      return player:hasSkill(self) and data ~= self and data.visible and data:isPlayerSkill(player)
      and target == player and player:hasSkill(data, true) and not player:isKongcheng() and #cards > 0
    end,
    on_use = function(self, _, target, player, data)
      local room = player.room
      local cards = table.filter(player:getCardIds("h"), function (id)
        return Fk:getCardById(id):getMark("@@zzz__hanque-inhand") == 0
      end)
      if not player:isKongcheng() and #cards > 0 then
        local card = player.room:askForCard(player, 1, 1, false, self.name, false, tostring(Exppattern{ id = cards }), "#zzz__hanque_turnover")
        room:setCardMark(Fk:getCardById(card[1]), "@@zzz__hanque-inhand", 1)
      end
    end,

    refresh_events = {fk.PreCardUse},
    can_refresh = function(self, event, target, player, data)
      return target == player and not data.card:isVirtual() and data.card:getMark("@@zzz__hanque-inhand") > 0
    end,
    on_refresh = function(self, event, target, player, data)
      data.extraUse = true
    end,
  }
  local hanque_trigger = fk.CreateTriggerSkill{
    name = "#zzz__hanque_trigger",
    anim_type = "defensive",
    events = {fk.CardRespondFinished, fk.CardUseFinished},
    can_trigger = function(self, event, target, player, data)
    if table.every(player.room:getOtherPlayers(player, false), function(p)
        return player:getHandcardNum() > p:getHandcardNum() end) then return false end
      local cards = table.filter(player:getCardIds("h"), function (id)
        return Fk:getCardById(id):getMark("@@zzz__hanque-inhand") == 0
      end)
      return target == player and player:hasSkill(self) and not player:isKongcheng() and not player.dead and
      data.responseToEvent and data.responseToEvent.from and #cards > 0
    end,
    on_use = function(self, event, target, player, data)
      local room = player.room
      local cards = table.filter(player:getCardIds("h"), function (id)
        return Fk:getCardById(id):getMark("@@zzz__hanque-inhand") == 0
      end)
      if not player:isKongcheng() and #cards > 0 then
      local card = player.room:askForCard(player, 1, 1, false, self.name, false, tostring(Exppattern{ id = cards }), "#zzz__hanque_turnover")
      room:setCardMark(Fk:getCardById(card[1]), "@@zzz__hanque-inhand", 1)
      end
    end,
  }
  local hanque_filter = fk.CreateFilterSkill{
    name = "#zzz__hanque_filter",
    card_filter = function(self, card, player, isJudgeEvent)
      return player:hasSkill(self, true) and card:getMark("@@zzz__hanque-inhand") > 0
      and (table.contains(player.player_cards[Player.Hand], card.id))
    end,
    view_as = function(self, card)
      return Fk:cloneCard("ice__slash", card.suit, card.number)
    end,
  }
  local hanque_targetmod = fk.CreateTargetModSkill{
    name = "#zzz__hanque_targetmod",
    bypass_times = function(self, player, skill, scope, card)
      return card and card:getMark("@@zzz__hanque-inhand") > 0
    end,
    bypass_distances = function(self, player, skill, card, to)
      return card and card:getMark("@@zzz__hanque-inhand") > 0
    end,
  }

  hanque:addRelatedSkill(hanque_trigger)
  hanque:addRelatedSkill(hanque_filter)
  hanque:addRelatedSkill(hanque_targetmod)
  Miyabi:addSkill(hanque)

  Fk:loadTranslationTable{
    ["zzz__Miyabi"] = "星见雅", 
    ["#zzz__Miyabi"] = "狩虚佑世",
    ["cv:zzz__Miyabi"] = "阮从青",
    ["illustrator:zzz__Miyabi"] = "lagna",
    ["designer:zzz__Miyabi"] = "幽蝶化烬",

    ["zzz__shuangyue"] = "霜月",
    [":zzz__shuangyue"] = "连招技（牌+牌...，牌名字数和等于六，大于六则重置），你可以摸连招进度-2张牌。若为本轮首次发动，你可以改为摸三张牌。",
    ["zzz__hanque"] = "寒雀",
    [":zzz__hanque"] = "你响应牌或发动其他技能后，若你手牌数不为唯一最大，你可以令一张手牌视为无距离次数限制的冰【杀】。",

    ["@zzz__shuangyue"] = "霜月",
    ["#zzz__shuangyue-choice"] = "霜月：请选择摸牌数量！",
    ["#zzz__shuangyue-draw"] = "摸连招进度-2（即%arg）张牌",
    ["draw3__instead"] = "改为摸三张牌",
    ["@@zzz__hanque-inhand"] = "寒雀",
    ["#zzz__hanque_trigger"] = "寒雀",
    ["#zzz__hanque_filter"] = "寒雀",
    ["#zzz__hanque_targetmod"] = "寒雀",
    ["#zzz__hanque_turnover"] = "寒雀：请令一张手牌视为无距离次数限制的冰【杀】",

    ["$zzz__shuangyue"] = "兔兔伯爵，出击！",
    ["$zzz__hanque"] = "交给我吧！",
    ["~zzz__Miyabi"] = "这次我…输了啊…",
  }

  Fk:loadTranslationTable{
    ["zzz__Anby"] = "安比", 
    ["#zzz__Anby"] = "如出光影",
    ["cv:zzz__Anby"] = "宴宁",
    ["illustrator:zzz__Anby"] = "夜纭L",
    ["designer:zzz__Anby"] = "幽蝶化烬",

    ["zzz__yongpai"] = "涌湃",
    [":zzz__yongpai"] = "连招技（点数大于1+点数小于10），你可以摸一张牌，令前一个连招条件点数+1，后一个连招条件点数-1。你使用点数为两个连招条件之差的牌后，重置本技能。",
    ["zzz__tingshu"] = "霆枢",
    [":zzz__tingshu"] = "限定技，你可以重铸区域内所有牌以跳过一个阶段，若如此做，本回合结束后，你令任意名角色不能使用或打出本回合既被弃置又被重铸过的牌名。",

    ["$zzz__yongneng"] = "兔兔伯爵，出击！",
    ["$zzz__tingshu"] = "交给我吧！",
    ["~zzz__Anby"] = " ",
  }
  local zzz__jiyu = fk.CreateTriggerSkill{
    name = "zzz__jiyu",
    anim_type = "switch",
    switch_skill_name = "zzz__jiyu",
    events = {fk.DamageInflicted},
    can_trigger = function(self, _, target, player, data)
      if player:hasSkill(self) and (target == player or player:distanceTo(target) == 1) then
        if player:getSwitchSkillState(self.name, false) == fk.SwitchYang then
          return player:getMark("__hidden_general") == 0 and player:getMark("__hidden_deputy") == 0
        else
          return player.chained
        end
      end
    end,
    on_cost = function(self, event, target, player, data)
      if player:getSwitchSkillState(self.name) == fk.SwitchYang then
      return player.room:askForSkillInvoke(player, self.name, nil, "#zzz__jiyu1-await::"..target.id)
    elseif player:getSwitchSkillState(self.name) == fk.SwitchYin then
      return player.room:askForSkillInvoke(player, self.name, nil, "#zzz__jiyu2-await::"..target.id)
      end
    end,
    on_use = function(self, event, target, player, data)
      if player:getSwitchSkillState(self.name, true) == fk.SwitchYang then
        IntoHidden(player)
        return true
      elseif player:getSwitchSkillState(self.name, true) == fk.SwitchYin then
        player:setChainState(false)
        return true
      end
    end,
  }
  Evelyn:addSkill(zzz__jiyu)
  zzz__jiyu.isHiddenSkill = true

  local zzz__ruijue = fk.CreateTriggerSkill{
    name = "zzz__ruijue",
    anim_type = "offensive",
    events = {fk.ChainStateChanged, fk.TurnedOver, "fk.GeneralAppeared"},
    can_trigger = function(self, event, target, player, data)
      return target == player and player:hasSkill(self) and player.faceup and not player.chained
      and player:getMark("__hidden_general") == 0 and player:getMark("__hidden_deputy") == 0
    end,
    on_cost = function (self, event, target, player, data)
      local room = player.room
      local names = {}
      room.logic:getEventsOfScope(GameEvent.SkillEffect, 999, function(e)
        local use = e.data[3] 
        if use.attached_equip and Fk.all_card_types[use.attached_equip] then
          table.insertIfNeed(names, use)
        end
      end, Player.HistoryRound)
      room.logic:getEventsOfScope(GameEvent.UseCard, 999, function(e)
        local use = e.data[1]
        if use.card.type == Card.TypeEquip then
          table.insertIfNeed(names, use)
        end
      end, Player.HistoryRound)
      return player.room:askForSkillInvoke(player, self.name, nil, "#zzz__ruijue-invoke:::"..math.min(#names, 4))
      end,
    on_use = function (self, event, target, player, data)
      local room = player.room
      local names = {}
      room.logic:getEventsOfScope(GameEvent.SkillEffect, 999, function(e)
        local use = e.data[3]
        if use.attached_equip and Fk.all_card_types[use.attached_equip] then
          table.insertIfNeed(names, use)
        end
      end, Player.HistoryRound)
      room.logic:getEventsOfScope(GameEvent.UseCard, 999, function(e)
        local use = e.data[1]
        if use.card.type == Card.TypeEquip then
          table.insertIfNeed(names, use)
        end
      end, Player.HistoryRound)
      if #names > 0 then
        player:drawCards(math.min(#names, 4), self.name)
      end
      room:damage{
        from = player,
        to = player,
        damage = 1,
        damageType = fk.FireDamage,
        skillName = self.name,
      }
    end,
  }
  Evelyn:addSkill(zzz__ruijue)

  local zzz__liaosuo = fk.CreateTriggerSkill{
    name = "zzz__liaosuo",
    anim_type = "offensive",
    events = {fk.CardUsing},
    can_trigger = function(self, event, target, player, data)
      return target == player and player:hasSkill(self) and
      data.extra_data and data.extra_data.combo_skill and data.extra_data.combo_skill[self.name]
    end,
    on_cost = function (self, event, target, player, data)
    local room = player.room
    local invoke = player.room:askForSkillInvoke(player, self.name, nil)
      if invoke then
        room:setPlayerMark(player, "@zzz__liaosuo", 0)
        return true
      else
        room:setPlayerMark(player, "@zzz__liaosuo", 0)
      end
    end,
    on_use = function (self, event, target, player, data)
      local room = player.room
      local targets = {}
      room.logic:getEventsOfScope(GameEvent.UseCard, 999, function(e)
        local use = e.data[1]
        for _, id in ipairs(TargetGroup:getRealTargets(use.tos)) do
          table.insertIfNeed(targets, id)
        end
      end, Player.HistoryTurn)
      table.insertIfNeed(targets, player.id)
      if #targets > 0 then
        local to = room:askForChoosePlayers(player, targets, 1, 999,
        "#zzz__liaosuo_chain", self.name, false)
        if #to > 0 then
          for _, id in ipairs(to) do
            local tar = room:getPlayerById(id)
            if not tar.dead and not tar.chained then
              tar:setChainState(true)
            end
          end
        end
      end
    end,

    refresh_events = {fk.AfterCardUseDeclared},
    can_refresh = function (self, event, target, player, data)
      return target == player and player:hasSkill(self, true) and data.card
    end,
    on_refresh = function (self, event, target, player, data)
      local room = player.room
      local mark = player:getTableMark("@zzz__liaosuo")
      local clear = true
      if #mark == 0 and type(data.tos) == "table" and not data.card.multiple_targets then
        room:addTableMark(player, "@zzz__liaosuo", "√")
        clear = false
      elseif #mark == 1 and (type(data.tos) ~= "table" or data.card.multiple_targets) then
        room:addTableMark(player, "@zzz__liaosuo", "√")
        clear = false
      end
      if clear then
        room:setPlayerMark(player, "@zzz__liaosuo", 0)
      end
      if #player:getTableMark("@zzz__liaosuo") == 2 then
          data.extra_data = data.extra_data or {}
          data.extra_data.combo_skill = data.extra_data.combo_skill or {}
          data.extra_data.combo_skill[self.name] = true
      return
      end
    end,

    on_lose = function (self, player, is_death)
      player.room:setPlayerMark(player, "@zzz__liaosuo", 0)
    end,
  }
  Evelyn:addSkill(zzz__liaosuo)

  Fk:loadTranslationTable{
    ["zzz__Evelyn"] = "伊芙琳", 
    ["#zzz__Evelyn"] = "索燃无畏",
    ["cv:zzz__Evelyn"] = "李婵妃",
    ["illustrator:zzz__Evelyn"] = "奏Kata",
    ["designer:zzz__Evelyn"] = "幽蝶化烬",

    ["zzz__jiyu"] = "羁预",
    [":zzz__jiyu"] = "隐匿。转换技，你距离1以内的角色受到伤害时，你可以改为，阳：你隐匿；阴：你重置。",
    ["zzz__ruijue"] = "锐觉",
    [":zzz__ruijue"] = "你复原武将牌后，可以摸本轮使用或弃置的装备牌数张牌（至多四张），受到1点火焰伤害。",
    ["zzz__liaosuo"] = "燎索",
    [":zzz__liaosuo"] = "连招技（单目标牌+非单目标牌），你可以令任意名角色横置（需为你或本回合被使用过牌）。",

    ["#zzz__jiyu1-await"] = "羁预（阳）：是否防止 %dest 即将受到的伤害，然后隐匿？",
    ["#zzz__jiyu2-await"] = "羁预（阴）：是否防止 %dest 即将受到的伤害，然后重置？",
    ["#zzz__ruijue-invoke"] = "锐觉：是否摸%arg张牌，然后受到1点火焰伤害？",
    ["@zzz__liaosuo"] = "燎索",
    ["#zzz__liaosuo_chain"] = "燎索：请横置你或任意名本回合被使用过牌的角色。",

    ["$zzz__jiyu"] = "交给我吧！",
    ["$zzz__liaosuo"] = "兔兔伯爵，出击！",
    ["~zzz__Evelyn"] = " ",
  }

  Fk:loadTranslationTable{
    ["zzz__Corin"] = "可琳", 
    ["#zzz__Corin"] = "锯莉砺征",
    ["cv:zzz__Corin"] = "沐霏",
    ["illustrator:zzz__Corin"] = "YukinaZM",
    ["designer:zzz__Corin"] = "幽蝶化烬",

    ["zzz__xiaochu"] = "啸簇",
    [":zzz__xiaochu"] = "连招技（牌+牌），。",

    ["$zzz__xiaochu"] = "交给我吧！",
    ["~zzz__Corin"] = " ",
  }

  local zzz__wanwo = fk.CreateTriggerSkill{
    name = "zzz__wanwo",
    frequency = Skill.Compulsory,
    events = {fk.RoundStart, fk.Damaged, fk.RoundEnd, fk.Damage},
    can_trigger = function(self, event, target, player, data)
      if not player:hasSkill(self) then return false end
      local mark = {}
      for _, p in ipairs(player.room:getAllPlayers()) do
        if not p:isKongcheng() then
          for _, id in ipairs(p:getCardIds("h")) do
            if Fk:getCardById(id):getMark("@@zzz__xiqu") ~= 0 and #Fk:getCardById(id, true):getAvailableTargets(player, {bypass_times = true}) > 0 then
              table.insertIfNeed(mark, id)
            end
          end
        end
      end
      local wanwo = false
      for i = 0, 110, 1 do
        local name = i == 0 and "zzz__xiqu" or "zzz"..i.."__xiqu"
        if player:hasSkill(name, true) and player:usedSkillTimes(name, Player.HistoryGame) == 0 then
            wanwo = true
          break
        end
      end
      return event == fk.RoundStart or (event == fk.RoundEnd and #mark > 0 and wanwo) or
      (({event == fk.Damage and #mark > 0 and wanwo} or event == fk.Damaged) and target == player)
    end,
    on_use = function(self, event, target, player, data)
      local room = player.room
      if event == fk.RoundStart or event == fk.Damaged then
        for i = 0, 110, 1 do
          local name = i == 0 and "zzz__xiqu" or "zzz"..i.."__xiqu"
          if not player:hasSkill(name, true) then
            player:setSkillUseHistory(name, 0, Player.HistoryGame)
            room:handleAddLoseSkills(player, name, nil, true, false)
            break
          end
        end
      elseif event == fk.RoundEnd or event == fk.Damage then
        local mark = player:getTableMark("zzz__wanwo")
        room:setPlayerMark(player, "zzz__wanwo", 0) --每次发动先初始化代替技能流程结束以后的清理
        for _, p in ipairs(player.room:getAllPlayers()) do
          if not p:isKongcheng() then
            for _, id in ipairs(p:getCardIds("h")) do
              if Fk:getCardById(id):getMark("@@zzz__xiqu") ~= 0 and #Fk:getCardById(id, true):getAvailableTargets(player, {bypass_times = true}) > 0 then
                table.insertIfNeed(mark, id)
              end
            end
          end
        end
        room:setPlayerMark(player, "zzz__wanwo", #mark > 0 and mark or 0)
          if #mark > 0 then
            local wanwo = false
            for i = 0, 110, 1 do
              local name = i == 0 and "zzz__xiqu" or "zzz"..i.."__xiqu"
              if player:hasSkill(name, true) and player:usedSkillTimes(name, Player.HistoryGame) == 0 then
                room:handleAddLoseSkills(player, "-"..name, nil, true, false)
                  wanwo = true
                break
              end
            end
          if wanwo then
            local use = U.askForUseRealCard(room, player, mark, nil, self.name, "#zzz__wanwo-ask",
            {expand_pile = mark, bypass_times = true}, true, false)
            if use then
              use = {
                card = use.card,
                from = player.id,
                tos = use.tos,
                extraUse = true
              }
              use.card.skillName = self.name
              room:useCard(use)
            end
          end
        end
      end
    end,
  }
  SilverAnby:addSkill(zzz__wanwo)

  local zzz__yishan = fk.CreateTriggerSkill{
    name = "zzz__yishan",
    anim_type = "offensive",
    events = {fk.CardUsing},
    can_trigger = function(self, event, target, player, data)
      return target == player and player:hasSkill(self) and
      data.extra_data and data.extra_data.combo_skill and data.extra_data.combo_skill[self.name]
    end,
    on_cost = function (self, event, target, player, data)
    local invoke = player.room:askForSkillInvoke(player, self.name, nil)
      if invoke then
        player.room:setPlayerMark(player, "@zzz__yishan", string.format("%s %s %s", "-", "-", "-"))
        return true
      else
        player.room:setPlayerMark(player, "@zzz__yishan", string.format("%s %s %s", "-", "-", "-"))
      end
    end,
    on_use = function (self, event, target, player, data)
      local room = player.room
      local choices = {"draw1"}
      for i = 0, 110, 1 do
        local name = i == 0 and "zzz__xiqu" or "zzz"..i.."__xiqu"
        if player:hasSkill(name, true) and player:usedSkillTimes(name, Player.HistoryGame) > 0 then
          table.insert(choices, "reset_xiqu")
          break
        end
      end
      local choice = room:askForChoice(player, choices, self.name, "#zzz__yishan-choice")
      local choices2 = {}
      if choice == "draw1" then
        for i = 0, 110, 1 do
          local name = i == 0 and "zzz__xiqu" or "zzz"..i.."__xiqu"
          if player:hasSkill(name, true) and player:usedSkillTimes(name, Player.HistoryGame) > 0 then
            table.insert(choices2, "reset_xiqu")
            break
          end
        end
        player:drawCards(1, self.name)
      elseif choice == "reset_xiqu" then
        table.insert(choices2, "draw1")
        for i = 0, 110, 1 do
          local name = i == 0 and "zzz__xiqu" or "zzz"..i.."__xiqu"
          if player:hasSkill(name, true) and player:usedSkillTimes(name, Player.HistoryGame) > 0 then
            player:setSkillUseHistory(name, 0, Player.HistoryGame)
            break
          end
        end
      end
      local x = 0
      for i = 0, 110, 1 do
        local name = i == 0 and "zzz__xiqu" or "zzz"..i.."__xiqu"
        if player:hasSkill(name, true) and player:usedSkillTimes(name, Player.HistoryGame) == 0 then
          x = x + 1
        end
      end
      if player:getHandcardNum() <= x then
        table.insert(choices2, "thunder__yishan")
        if not player.dead and #choices2 > 0 then
          local choice2 = room:askForChoice(player, choices2, self.name, "#zzz__yishan-choice")
          if choice2 == "draw1" then
            player:drawCards(1, self.name)
          elseif choice2 == "reset_xiqu" then
            for i = 0, 110, 1 do
              local name = i == 0 and "zzz__xiqu" or "zzz"..i.."__xiqu"
              if player:hasSkill(name, true) and player:usedSkillTimes(name, Player.HistoryGame) > 0 then
                player:setSkillUseHistory(name, 0, Player.HistoryGame)
                break
              end
            end
          elseif choice2 == "thunder__yishan" then
            local to = room:askForChoosePlayers(player, table.map(room:getAllPlayers(), Util.IdMapper), 1, 1,
            "#zzz__yishan-damage", self.name, false)
              if #to > 0 then
              room:damage{
                from = player,
                to = room:getPlayerById(to[1]),
                damage = 1,
                damageType = fk.ThunderDamage,
                skillName = self.name,
              }
              end
          end
        end
      end
    end,

    refresh_events = {fk.AfterCardUseDeclared},
    can_refresh = function (self, event, target, player, data)
      return target == player and player:hasSkill(self, true)
    end,
    on_refresh = function (self, event, target, player, data)
      local room = player.room
      if player:getMark("@zzz__yishan") == string.format("%s %s %s", "-", "-", "-") then
        room:setPlayerMark(player, "@zzz__yishan", string.format("%s %s %s", "<font color=\"green\">✔</font>", "-", "-"))
      elseif player:getMark("@zzz__yishan") == string.format("%s %s %s", "<font color=\"green\">✔</font>", "-", "-") then
        room:setPlayerMark(player, "@zzz__yishan", string.format("%s %s %s", "<font color=\"green\">✔</font>", "<font color=\"green\">✔</font>", "-"))
      elseif player:getMark("@zzz__yishan") == string.format("%s %s %s", "<font color=\"green\">✔</font>", "<font color=\"green\">✔</font>", "-") then
        room:setPlayerMark(player, "@zzz__yishan", string.format("%s %s %s", "<font color=\"green\">✔</font>",
        "<font color=\"green\">✔</font>", "<font color=\"green\">✔</font>"))
      else 
        room:setPlayerMark(player, "@zzz__yishan", string.format("%s %s %s", "-", "-", "-"))
      end
      if player:getMark("@zzz__yishan") == string.format("%s %s %s", "<font color=\"green\">✔</font>",
       "<font color=\"green\">✔</font>", "<font color=\"green\">✔</font>") then
          data.extra_data = data.extra_data or {}
          data.extra_data.combo_skill = data.extra_data.combo_skill or {}
          data.extra_data.combo_skill[self.name] = true
      return
      end
    end,

    on_acquire = function (self, player, is_start)
      player.room:setPlayerMark(player, "@zzz__yishan", string.format("%s %s %s", "-", "-", "-"))
    end,

    on_lose = function (self, player, is_death)
      player.room:setPlayerMark(player, "@zzz__yishan", 0)
    end,
  }
  SilverAnby:addSkill(zzz__yishan)
  local zzz__xiqu_delay = fk.CreateTriggerSkill{
    name = "#zzz__xiqu_delay",
    anim_type = "drawcard",
    --[[events = {fk.AfterCardsMove},
    can_trigger = function(self, event, target, player, data)
      return not player.dead and data.extra_data and data.extra_data.zzz__xiqu
      and data.extra_data.zzz__xiqu[player.id] and data.extra_data.zzz__xiqu[player.id] == 1
    end,
    on_cost = Util.TrueFunc,
    on_use = function (self, event, target, player, data)
      local room = player.room
      local get = {}
      local names = {"slash", "fire__slash", "thunder__slash", "ice__slash"}
      if not Fk.all_card_types["ice__slash"] then --军争一般都开吧？
        table.removeOne(names, "ice__slash")
      end
      if #names > 0 then
        table.insert(get, room:printCard(table.random(names, 1)[1], math.random(5), math.random(0, 14)).id)
        room:obtainCard(player, get, true, fk.ReasonJustMove, player.id, self.name, MarkEnum.DestructIntoDiscard)
      end
      data.extra_data = data.extra_data or {}
      data.extra_data.zzz__xiqu = data.extra_data.zzz__xiqu or {}
      data.extra_data.zzz__xiqu[player.id] = nil --防止多个锡躯重复获得杀
    end,]]

    refresh_events = {fk.AfterCardsMove},
    can_refresh = function (self, event, target, player, data)
      for _, move in ipairs(data) do
        if move.from then
          for _, info in ipairs(move.moveInfo) do
            if info.fromArea == Card.PlayerHand and Fk:getCardById(info.cardId):getMark("@@zzz__xiqu") ~= 0 then
              return true
            end
          end
        end
      end
    end,
    on_refresh = function (self, event, target, player, data)
      local room = player.room
      data.extra_data = data.extra_data or {}
      data.extra_data.zzz__xiqu = data.extra_data.zzz__xiqu or {}
      for _, move in ipairs(data) do
        if move.from then
          for _, info in ipairs(move.moveInfo) do
            local owner = Fk:getCardById(info.cardId):getMark("@@zzz__xiqu")
            if info.fromArea == Card.PlayerHand and owner ~= 0 then
              room:setCardMark(Fk:getCardById(info.cardId), "@@zzz__xiqu", 0)
              for _, p in ipairs(room:getAllPlayers()) do
                local mark = p:getTableMark("zzz__wanwo")
                if #mark > 0 then
                  table.removeOne(mark, info.cardId)
                  room:setPlayerMark(p, "zzz__wanwo", #mark > 0 and mark or 0)
                end
              end
              --[[if move.moveReason == fk.ReasonDiscard then
                data.extra_data.zzz__xiqu[owner] = 1 --多次同时弃置暂定一张印杀算了
              end]]
            end
          end
        end
      end
    end,
  }
  ---@param player Player @ 目标角色
  local function xiqu(player)
    for i = 0, 110, 1 do
      local skill = i == 0 and "zzz__xiqu" or "zzz"..i.."__xiqu"
      if player:hasSkill(skill, true) then
        return true
      end
    end
  end
  local zzz__xiqu_prohibit = fk.CreateProhibitSkill{
    name = "#zzz__xiqu_prohibit",
    prohibit_use = function(self, player, card)
      local cards = card:isVirtual() and card.subcards or {card.id}
      return table.find(cards, function(id) return Fk:getCardById(id):getMark("@@zzz__xiqu") ~= 0 end)
      and not xiqu(player)
    end,
  }

  Fk:loadTranslationTable{
    ["zzz__SilverAnby"] = "安比", 
    ["#zzz__SilverAnby"] = "锡白怀心",
    ["cv:zzz__SilverAnby"] = "宴宁",
    ["illustrator:zzz__SilverAnby"] = "netural1175",
    ["designer:zzz__SilverAnby"] = "幽蝶化烬",

    ["zzz__wanwo"] = "万我",
    [":zzz__wanwo"] = "锁定技，每轮开始时或你受到伤害后，你获得一个“锡躯”。每轮结束后或你造成伤害后，你失去一个可用“锡躯”，使用一张所有角色的“锡躯”牌。",
    ["zzz__yishan"] = "一闪",
    [":zzz__yishan"] = "连招技（牌+牌+牌），你可以摸一张牌或重置一个“锡躯”，若你的手牌数不大于可用“锡躯”数，你执行另一项或分配1点雷电伤害。",

    ["zzz__wanwo_active"] = "万我",
    ["#zzz__wanwo-ask"] = "万我：请使用一张“锡躯”标记过的牌！",
    ["@zzz__yishan"] = "一闪",
    ["#zzz__yishan-choice"] = "一闪：请选择一项！",
    ["thunder__yishan"] = "分配雷电伤害",
    ["#zzz__yishan-damage"] = "一闪：请分配1点雷电伤害！",
    ["reset_xiqu"] = "重置锡躯",
    ["zzz__xiqu"] = "锡躯",
    ["#zzz__xiqu_delay"] = "锡躯",
    [":zzz__xiqu"] = "宗族技，限定技，出牌阶段，你可以展示一名角色的一张手牌，令其选择一项：此牌不可被没有“锡躯”的角色使用；重铸此牌，令你获得一张【杀】。",
    ["@@zzz__xiqu"] = "锡躯",
    ["#zzz__xiqu-skill"] = "锡躯：请选择一项！",
    ["zzz__xiqu__seal"] = "令此牌不能被没有锡躯的角色使用",
    ["zzz__xiqu__recast"] = "重铸此牌，令对方获得一张【杀】",

    ["$zzz__liaosuo"] = "兔兔伯爵，出击！",
    ["$zzz__huwei"] = "交给我吧！",
    ["~zzz__SilverAnby"] = " ",
  }

  Fk:loadTranslationTable{
    ["zzz__SoldierEleven"] = "11号", 
    ["#zzz__SoldierEleven"] = "火烈无情",
    ["cv:zzz__SoldierEleven"] = "陈雨",
    ["illustrator:zzz__SoldierEleven"] = "好奇心吧",
    ["designer:zzz__SoldierEleven"] = "爬山虎",

    ["zzz__zhenhuo"] = "镇火",
    [":zzz__zhenhuo"] = "连招技（牌+牌），。",

    ["$zzz__zhenhuo"] = "兔兔伯爵，出击！",
    ["~zzz__SoldierEleven"] = " ",
  }

  local zzz__canqiao_active = fk.CreateActiveSkill{
    name = "zzz__canqiao_active",
    prompt = function(self)
      local num = Self:getMark("@zzz__canqiao")
      return "#zzz__canqiao-skill:::"..num
    end,
    interaction = function(self)
      local names = {"zzz__canqiao_card", "zzz__canqiao_skill"}
      return UI.ComboBox {choices = names}
    end,
    card_filter = function(self, to_select, selected)
      if self.interaction.data == "zzz__canqiao_card" then
        return Fk:getCardById(to_select):getMark("@@zzz__canqiao-inhand-round") > 0
      elseif self.interaction.data == "zzz__canqiao_skill" then
        return false
      end
    end,
    feasible = function (self, selected, selected_cards)
      local x = 0
      for i = 0, 110, 1 do
        local name = i == 0 and "zzz__xiqu" or "zzz"..i.."__xiqu"
        if Self:hasSkill(name, true) then
          x = x + 1
        end
      end
      local num = Self:getMark("@zzz__canqiao")
      if self.interaction.data == "zzz__canqiao_card" then
        return #selected_cards == num
      elseif self.interaction.data == "zzz__canqiao_skill" then
        return x >= num
      end
    end,
  }
  Fk:addSkill(zzz__canqiao_active)

  local zzz__canqiao = fk.CreateTriggerSkill{
    name = "zzz__canqiao",
    events = {fk.DamageInflicted, fk.RoundEnd},
    can_trigger = function(self, event, target, player, data)
      if not player:hasSkill(self) then return false end
      if (event == fk.RoundEnd and player:getMark("zzz__canqiao1-round") > 0 and player:getMark("zzz__canqiao2-round") > 0) or
      (event == fk.DamageInflicted and target == player) then
        return true
      end
    end,
    on_cost = function(self, event, target, player, data)
      if event == fk.RoundEnd then
        return true
      elseif event == fk.DamageInflicted then
        local y = player:getMark("@zzz__canqiao")
        local success, ret = player.room:askForUseActiveSkill(player, "zzz__canqiao_active",
          "#zzz__canqiao-skill:::"..y, true)
        if success and ret then
          if ret.interaction == "zzz__canqiao_card" then
            self.cost_data = ret.cards
            return true
          elseif ret.interaction == "zzz__canqiao_skill" then
            self.cost_data = "zzz__canqiao_skill"
            return true
          end
        end
      end
    end,
    on_use = function(self, event, target, player, data)
      local room = player.room
      local y = player:getMark("@zzz__canqiao")
      if event == fk.DamageInflicted then
        if self.cost_data ~= "zzz__canqiao_skill" then
          if y == 0 then
            room:addPlayerMark(player, "@zzz__canqiao", 1)
            return true
          else
            room:addPlayerMark(player, "@zzz__canqiao", 1)
            room:throwCard(self.cost_data, self.name, player, player)
            return true
          end
        elseif self.cost_data == "zzz__canqiao_skill" then  
          if y == 0 then
            room:addPlayerMark(player, "@zzz__canqiao", 1)
            return true
          else
            room:addPlayerMark(player, "@zzz__canqiao", 1)
            local skills2 = {}          --优先插入失去发动过的锡躯
            for i = 0, 110, 1 do
              if #skills2 == y then break end
              local name = i == 0 and "zzz__xiqu" or "zzz"..i.."__xiqu"
              if player:hasSkill(name, true) then
                if player:usedSkillTimes(name, Player.HistoryGame) > 0 then
                table.insert(skills2, name)
                end
              end
            end
            for i = 0, 110, 1 do
              if #skills2 == y then break end
              local name = i == 0 and "zzz__xiqu" or "zzz"..i.."__xiqu"
              if player:hasSkill(name, true) then
                if player:usedSkillTimes(name, Player.HistoryGame) == 0 then
                table.insert(skills2, name)
                end
              end
            end
            if #skills2 == y then
            room:handleAddLoseSkills(player, "-"..table.concat(skills2, "|-"), nil, true, false)
            return true
            end
          end
        end
      elseif event == fk.RoundEnd then
        local get = {}
        local name
        if Fk.all_card_types["shade"] then
          name = "shade"
        elseif Fk.all_card_types["rfenghou__shade"] then
          name = "rfenghou__shade"
        elseif Fk.all_card_types["tey__shade"] then --最后再印提瓦特自己的影
          name = "tey__shade"
        end
        assert(name, "服务器未加入【影】！请联系管理员安装“江山如故”或“封侯”或启用“提瓦特卡牌”包")
        table.insert(get, room:printCard(name, 1, 1).id)
        room:obtainCard(player, get, true, fk.ReasonJustMove, player.id, self.name, MarkEnum.DestructIntoDiscard)
        room:setPlayerMark(player, "@zzz__canqiao", 0)
      end
    end,

    refresh_events = {fk.RoundStart, fk.AfterCardsMove, fk.EventLoseSkill},
    can_refresh = function (self, event, target, player, data)
      if not player:hasSkill(self) then return false end
      if event == fk.RoundStart then
        return true
      elseif event == fk.AfterCardsMove and player:isKongcheng() then
        for _, move in ipairs(data) do
          if move.from == player.id then
            for _, info in ipairs(move.moveInfo) do
              return info.fromArea == Card.PlayerHand
            end
          end
        end
      elseif event == fk.EventLoseSkill and target == player then
        local alllost = true
        for i = 0, 110, 1 do
          local name = i == 0 and "zzz__xiqu" or "zzz"..i.."__xiqu"
          if data.name == name then
            for p = 0, 110, 1 do
              local name2 = p == 0 and "zzz__xiqu" or "zzz"..p.."__xiqu"
              if player:hasSkill(name2, true) and name ~= name2 then --排除计入正在失去的锡躯
                alllost = false
              end
            end
            return alllost
          end
        end
      end
    end,
    on_refresh = function (self, event, target, player, data)
      local room = player.room
      if event == fk.RoundStart then
        if not player:isKongcheng() then
          for _, id in ipairs(player:getCardIds("h")) do
            room:setCardMark(Fk:getCardById(id), "@@zzz__canqiao-inhand-round", 1)
          end
        end
      elseif event == fk.AfterCardsMove then
        room:setPlayerMark(player, "zzz__canqiao1-round", 1)
      elseif event == fk.EventLoseSkill then
        room:setPlayerMark(player, "zzz__canqiao2-round", 1)
      end
    end,

    on_lose = function (self, player, is_death)
      local room = player.room
      room:setPlayerMark(player, "@zzz__canqiao", 0)
    end,
  }
  Cuiji:addSkill(zzz__canqiao)

  local zzz__yanshen = fk.CreateActiveSkill{
    name = "zzz__yanshen",
    anim_type = "drawcard",
    prompt = "#zzz__yanshen",
    can_use = function(self, player)
      return player:usedSkillTimes(self.name, Player.HistoryPhase) <= 1
    end,
    interaction = function(self)
      local names = {"card_to_skill"}
      local y = 0
      for i = 0, 110, 1 do
        local name = i == 0 and "zzz__xiqu" or "zzz"..i.."__xiqu"
        if Self:hasSkill(name, true) then
          if Self:usedSkillTimes(name, Player.HistoryGame) > 0 then
            y = y + 1
          end
        end
      end
      if y >= 2 then
        table.insertIfNeed(names, "used_xiqu_mutiple")
      end
      if #names > 0 then
      return UI.ComboBox {choices = names}
      end
    end,
    card_filter = function(self, to_select, selected)
      if self.interaction.data == "card_to_skill" then
        return table.every(selected, function (id) return Fk:getCardById(id).trueName == Fk:getCardById(to_select).trueName end)
      elseif self.interaction.data == "used_xiqu_mutiple" then
        return false
      end
    end,
    feasible = function (self, selected, selected_cards)
      if self.interaction.data == "card_to_skill" then
        return #selected_cards == 2
      elseif self.interaction.data == "used_xiqu_mutiple" then
        return true
      end
    end,
    target_filter = Util.FalseFunc,
    on_use = function(self, room, effect)
      local player = room:getPlayerById(effect.from)
      if self.interaction.data == "card_to_skill" then
      room:throwCard(effect.cards, self.name, player, player)
      local skills = {}
        for i = 0, 110, 1 do
          local name = i == 0 and "zzz__xiqu" or "zzz"..i.."__xiqu"
          if not player:hasSkill(name, true) then
            player:setSkillUseHistory(name, 0, Player.HistoryGame)
            table.insert(skills, name)
          end
          if #skills == 1 then break end
        end
      room:handleAddLoseSkills(player, skills, nil, true, false)
      elseif self.interaction.data == "used_xiqu_mutiple" then
        local skills2 = {}
        for i = 0, 110, 1 do
          local name = i == 0 and "zzz__xiqu" or "zzz"..i.."__xiqu"
          if player:hasSkill(name, true) then
            if player:usedSkillTimes(name, Player.HistoryGame) > 0 then
            table.insert(skills2, name)
            end
          end
          if #skills2 == 2 then break end
        end
      room:handleAddLoseSkills(player, "-"..table.concat(skills2, "|-"), nil, true, false)
      room:addPlayerMark(player, "@zzz__yanshen", 1)
      end
    end,
  }
  local zzz__yanshen_targetmod = fk.CreateTargetModSkill{
    name = "#zzz__yanshen_targetmod",
    residue_func = function(self, player, skill, scope)
      if skill.trueName == "slash_skill" and scope == Player.HistoryPhase then
        return player:getMark("@zzz__yanshen")
      end
    end,
  }

  zzz__yanshen:addRelatedSkill(zzz__yanshen_targetmod)
  Cuiji:addSkill(zzz__yanshen)
  Fk:loadTranslationTable{
    ["zzz__Cuiji"] = "崔姬", 
    ["#zzz__Cuiji"] = "暗淬无回",
    ["cv:zzz__Cuiji"] = "钟可",
    ["illustrator:zzz__Cuiji"] = "米哈游",
    ["designer:zzz__Cuiji"] = "以火修功",

    ["zzz__canqiao"] = "残壳",
    [":zzz__canqiao"] = "你受到伤害时，可以改为弃置X张本轮开始时的手牌或失去X个“锡躯”。每轮结束后，若你本轮失去过所有手牌与所有“锡躯”，你获得一张【影】并重置本技能。X为你已发动本技能的次数。",
    ["zzz__yanshen"] = "衍身",
    [":zzz__yanshen"] = "出牌阶段限两次，你可以弃置两张同名牌并获得一个“锡躯”，或失去两个不可用的“锡躯”并令你使用【杀】的次数+1。",

    ["@zzz__canqiao"] = "残壳",
    ["zzz__canqiao_active"] = "残壳",
    ["zzz__canqiao_card"] = "弃置手牌",
    ["zzz__canqiao_skill"] = "失去锡躯",
    ["#zzz__canqiao-skill"] = "残壳：是否弃置%arg张本轮开始时的手牌，或失去等量个锡躯（优先发动过的），防止你即将受到的伤害？",
    ["@@zzz__canqiao-inhand-round"] = "残壳",
    ["#zzz__yanshen"] = "衍身：请根据选项选择弃置的牌或直接点击确定",
    ["card_to_skill"] = "弃同名牌获得技能",
    ["used_xiqu_mutiple"] = "锡躯转化出杀次数",
    ["@zzz__yanshen"] = "衍身",

    ["$zzz__zhenhuo"] = "兔兔伯爵，出击！",
    ["~zzzz__Cuiji"] = " ",
  }
  local zzz__ranyin = fk.CreateViewAsSkill{
    name = "zzz__ranyin",
    anim_type = "offensive",
    pattern = "analeptic",
    prompt = "#zzz__ranyin",
    card_filter = Util.FalseFunc,
    view_as = function(self, cards)
      local c = Fk:cloneCard("analeptic")
      c.skillName = self.name
      return c
    end,
    before_use = function(self, player, use)
      player.room:setPlayerMark(player, "@@zzz__ranyin_readying", 1)
      use.extraUse = true
    end,
    enabled_at_play = function(self, player)
      return player:usedSkillTimes(self.name, Player.HistoryGame) == 0
    end,
    enabled_at_response = function(self, player, res)
      local to_use = Fk:cloneCard("analeptic")
      return not res and Fk.currentResponsePattern and Exppattern:Parse(Fk.currentResponsePattern):match(to_use)
      and player:usedSkillTimes(self.name, Player.HistoryGame) == 0
    end,
  }
  local zzz__ranyin_reset = fk.CreateActiveSkill{
    name = "zzz__ranyin_reset",
    anim_type = "offensive",
    min_card_num = 0,
    max_card_num = 3,
    target_num = 0,
    interaction = function(self)
      local all_choices
      if Self:usedSkillTimes("zzz__ranyin", Player.HistoryGame) > 0 and Self:usedSkillTimes("zzz__ranyin", Player.HistoryRound) == 0 then
        all_choices = {"ranyin_resett", "ranyin_check2"}
      elseif Self:usedSkillTimes("zzz__ranyin", Player.HistoryGame) == 0 then
        all_choices = {"ranyin_check1"}
      else
        all_choices = {"ranyin_check2"}
      end
      return UI.ComboBox {choices = all_choices}
    end,
    card_filter = function(self, to_select, selected)
      if self.interaction.data == "ranyin_resett" then
      return #selected < 3 and not Self:prohibitDiscard(Fk:getCardById(to_select))
      else
      return false
      end
    end,
    target_filter = Util.FalseFunc,
    on_use = function(self, room, effect)
      local player = room:getPlayerById(effect.from)
      if self.interaction.data == "ranyin_resett" then
        room:throwCard(effect.cards, "zzz__ranyin", player, player)
        player:setSkillUseHistory("zzz__ranyin", 0, Player.HistoryGame)
        player:setSkillUseHistory("zzz__ranyin", 0, Player.HistoryRound)
        room:setPlayerMark(player, "@@zzz__ranyin_readying", 0)
      end
    end,
    feasible = function (self, selected, selected_cards)
      return self.interaction.data ~= "ranyin_check1" and self.interaction.data ~= "ranyin_check2"
      and ((self.interaction.data == "ranyin_resett" and #selected_cards == 3))
    end,
  }
  local zzz__ranyin_true = fk.CreateTriggerSkill{
    name = "#zzz__ranyin_true",
    anim_type = "offensive",
    events = {fk.TurnEnd},
    can_trigger = function(self, event, target, player, data)
      return target == player and player:hasSkill("zzz__ranyin") and player:getMark("@@zzz__ranyin_readying") > 0
    end,
    on_cost = Util.TrueFunc,
    on_use = function(self, event, target, player, data)
      local room = player.room
      room:damage{
        from = player,
        to = player,
        damage = 1,
        damageType = fk.FireDamage,
        skillName = "zzz__ranyin",
      }
    end,

    refresh_events = {fk.AfterDrawPileShuffle},
    can_refresh = function(self, event, target, player, data)
      return player:getMark("@@zzz__ranyin_readying") > 0
    end,
    on_refresh = function(self, event, target, player, data)
      local room = player.room
        room:setPlayerMark(player, "@@zzz__ranyin_readying", 0)
        player:setSkillUseHistory("zzz__ranyin", 0, Player.HistoryGame)
        player:setSkillUseHistory("zzz__ranyin", 0, Player.HistoryRound)
    end,
 
    on_lose = function (self, player, is_death)
      local room = player.room
        room:setPlayerMark(player, "@@zzz__ranyin_readying", 0)
        player:setSkillUseHistory("zzz__ranyin", 0, Player.HistoryGame)
        player:setSkillUseHistory("zzz__ranyin", 0, Player.HistoryRound)
    end,
  }
  local zzz__ranyin_targetmod = fk.CreateTargetModSkill{
    name = "#zzz__ranyin_targetmod",
    bypass_times = function(self, player, skill, scope, card)
      return card and scope == Player.HistoryTurn and table.contains(card.skillNames, "zzz__ranyin")
    end,
  }
  local zzz__chihuan = fk.CreateTriggerSkill{
    name = "zzz__chihuan",
    anim_type = "offensive",
    events = {fk.CardUsing},
    can_trigger = function(self, event, target, player, data)
      return target == player and player:hasSkill(self) and
      data.extra_data and data.extra_data.combo_skill and data.extra_data.combo_skill[self.name]
    end,
    on_cost = function (self, event, target, player, data)
    local room = player.room
    local invoke = player.room:askForSkillInvoke(player, self.name, nil)
      if invoke then
        room:setPlayerMark(player, "@zzz__chihuan", 0)
        return true
      else
        room:setPlayerMark(player, "@zzz__chihuan", 0)
      end
    end,
    on_use = function (self, event, target, player, data)
      local room = player.room
      local x = 0
      room.logic:getEventsOfScope(GameEvent.UseCard, 999, function(e)
        local use = e.data[1]
        if use.from == target.id and use.card.trueName == "analeptic" then
          x = x + 1
        end
      end, Player.HistoryGame)
      local amazing_grace = Fk:cloneCard("amazing_grace")
      amazing_grace.skillName = self.name
      if player:prohibitUse(amazing_grace) or table.every(room.alive_players, function (p)
        return player:isProhibited(p, amazing_grace)
      end) then return end
      if x > 0 then
        for i = 1, x, 1 do
          if player.dead then break end
          local _, choice = U.askforChooseCardsAndChoice(player, room:getNCards(#room.alive_players),
          {"zzz__chihuan_throw", "zzz__chihuan_cancel"}, self.name, "#zzz__chihuan-invoke:::" .. i .. ":" .. x, nil, 0, 0)
          if choice == "zzz__chihuan_throw" then
            room:moveCardTo(room:getNCards(#room.alive_players), Card.DiscardPile, player.id, fk.ReasonPutIntoDiscardPile, self.name)
          else
            break 
          end
        end
      end
      if player:prohibitUse(amazing_grace) or table.every(room.alive_players, function (p)
        return player:isProhibited(p, amazing_grace)
      end) then return end
      room:useCard{
        from = player.id,
        card = amazing_grace
      }
    end,

    refresh_events = {fk.AfterCardUseDeclared},
    can_refresh = function (self, event, target, player, data)
      return target == player and player:hasSkill(self, true) and data.card
    end,
    on_refresh = function (self, event, target, player, data)
      local room = player.room
      local mark = player:getTableMark("@zzz__chihuan")
      local clear = true
      if #mark == 0 then
        room:addTableMark(player, "@zzz__chihuan", data.card.trueName)
        clear = false
      elseif #mark == 1 and data.card.trueName == mark[1] then
        room:addTableMark(player, "@zzz__chihuan", "√")
        clear = false
      end
      if clear then
        room:setPlayerMark(player, "@zzz__chihuan", 0)
      end
      if #player:getTableMark("@zzz__chihuan") == 2 then
        data.extra_data = data.extra_data or {}
        data.extra_data.combo_skill = data.extra_data.combo_skill or {}
        data.extra_data.combo_skill[self.name] = true
      return
      end
    end,

    on_lose = function (self, player, is_death)
      player.room:setPlayerMark(player, "@zzz__chihuan", 0)
    end,
  }
  local zzz__yehua = fk.CreateViewAsSkill{
    name = "zzz__yehua",
    anim_type = "switch",
    pattern = "analeptic",
    switch_skill_name = "zzz__yehua",
    prompt = function ()
      return Self:getSwitchSkillState("zzz__yehua", false) == fk.SwitchYang and "#zzz__yehua1" or "#zzz__yehua2"
    end,
    card_filter = Util.FalseFunc,
    view_as = function(self, cards)
      local c = Fk:cloneCard("analeptic")
      c.skillName = self.name
      return c
    end,
    before_use = function(self, player, use)
      local room = player.room 
      if player:getSwitchSkillState(self.name, true) == fk.SwitchYang then
        room:setPlayerMark(player, "@@zzz__yehua_skill-round", 1)
        room:addPlayerMark(player, MarkEnum.UncompulsoryInvalidity.."-round", 1)
      elseif player:getSwitchSkillState(self.name, true) == fk.SwitchYin then
        for _, id in ipairs(room:getOtherPlayers(player)) do
          room:setPlayerMark(id, "@@zzz__yehua_skill-turn", 1)
          room:addPlayerMark(id, MarkEnum.UncompulsoryInvalidity.."-turn", 1)
        end
      end
    end,
    enabled_at_play = function(self, player)
      return true
    end,
    enabled_at_response = function(self, player, res)
      local to_use = Fk:cloneCard("analeptic")
      return not res and Fk.currentResponsePattern and Exppattern:Parse(Fk.currentResponsePattern):match(to_use)
    end,
  }

  local zzz__haoxie = fk.CreateTriggerSkill{
    name = "zzz__haoxie",
    frequency = Skill.Compulsory,
    can_trigger = Util.FalseFunc,
  }

  zzz__ranyin:addRelatedSkill(zzz__ranyin_reset)
  zzz__ranyin:addRelatedSkill(zzz__ranyin_true)
  zzz__ranyin:addRelatedSkill(zzz__ranyin_targetmod)
  Burnice:addSkill(zzz__ranyin)
  Burnice:addSkill(zzz__chihuan)
  Burnice:addSkill(zzz__yehua)

  Fk:loadTranslationTable{
    ["zzz__Burnice"] = "柏妮思", 
    ["#zzz__Burnice"] = "酒花易燃",
    ["cv:zzz__Burnice"] = "葛子瑞",
    ["illustrator:zzz__Burnice"] = "torino",
    ["designer:zzz__Burnice"] = "幽蝶化烬",

    ["zzz__ranyin"] = "燃饮",
    [":zzz__ranyin"] = "蓄势技，你可以视为使用无次数限制的【酒】。回合结束时，若本技能蓄势，你受到1点火焰伤害。",
    ["zzz__chihuan"] = "炽欢",
    [":zzz__chihuan"] = "连招技（牌+牌，牌名相同），你可以视为使用可刷新X次的【五谷丰登】，X为你使用【酒】次数。",
    ["zzz__yehua"] = "夜话",
    [":zzz__yehua"] = "转换技，你可以视为使用【酒】且，阳：你本轮非锁定技失效；阴：其他角色本回合非锁定技失效。",

    ["zzz__ranyin_reset"] = "燃饮*",
    [":zzz__ranyin_reset"] = "出牌阶段，你可以弃牌重置已发动的“燃饮”或查看“燃饮”可用状态！",
    ["#zzz__ranyin_true"] = "燃饮",
    ["ranyin_check1"] = "燃饮：可用",
    ["ranyin_resett"] = "燃饮：弃牌重置",
    ["ranyin_check2"] = "燃饮：不可用",
    ["@@zzz__ranyin_readying"] = "燃饮 蓄势中",
    ["#zzz__ranyin"] = "燃饮：你可以视为使用无次数限制的【酒】，但蓄势期间你会承受自己造成的火伤。",
    ["@zzz__chihuan"] = "炽欢",
    ["zzz__chihuan_throw"] = "置入弃牌堆",
    ["zzz__chihuan_cancel"] = "确认五谷牌",
    ["#zzz__chihuan-invoke"] = "炽欢：请选择是否重新亮出五谷牌（%arg/%arg2）",
    ["#zzz__yehua1"] = "夜话：（阳）你可以视为使用【酒】，然后你的非锁定技本轮无效",
    ["#zzz__yehua2"] = "夜话：（阴）你可以视为使用【酒】，然后其他角色的非锁定技本回合无效",
    ["@@zzz__yehua_skill-round"] = "夜话 <font color=\"gray\">本轮非锁</font>",
    ["@@zzz__yehua_skill-turn"] = "夜话 <font color=\"gray\">本回非锁</font>",
    [":zzz__yehua_yang"] = "转换技，你可以视为使用【酒】且，<font color=\"#E0DB2F\">阳：你本轮非锁定技无效；</font>"..
    "<font color=\"gray\">阴：本回合其他角色非锁定技无效。</font>",
    [":zzz__yehua_yin"] = "转换技，你可以视为使用【酒】，然后，<font color=\"gray\">阳：你本轮非锁定技无效；</font>"..
    "<font color=\"#E0DB2F\">阴：本回合其他角色非锁定技无效。</font>",

    ["$zzz__ranyin"] = "兔兔伯爵，出击！",
    ["$zzz__chihuan"] = "兔兔伯爵，出击！",
    ["$zzz__yehua"] = "兔兔伯爵，出击！",
    ["~zzz__Burnice"] = " ",
  }

  local zzz__zhiyuan = fk.CreateViewAsSkill{
    name = "zzz__zhiyuan",
    prompt = "#zzz__zhiyuan-viewas",
    pattern = ".",
    interaction = function(self, player)
      local all_names = U.getAllCardNames("bt")
      local names = U.getViewAsCardNames(player, "zzz__zhiyuan", all_names)
      if #names > 0 then
        return U.CardNameBox { choices = names, all_choices = all_names }
      end
    end,
    card_filter = Util.FalseFunc,
    view_as = function(self, cards)
      if not self.interaction.data then return end
      local card = Fk:cloneCard(self.interaction.data)
      card.skillName = self.name
      return card
    end,
    before_use = function(self, player, use)
      player.room:setPlayerMark(player, "@@zzz__zhiyuan_readying", 1)
    end,
    enabled_at_play = function(self, player)
      return player:usedSkillTimes(self.name, Player.HistoryGame) == 0
    end,
    enabled_at_response = function(self, player, response)
      if response then return false end
      return player:usedSkillTimes(self.name, Player.HistoryGame) == 0 and
      #table.filter(U.getViewAsCardNames(player, self.name, U.getAllCardNames("bt")), function (name)
        return Fk.currentResponsePattern and Exppattern:Parse(Fk.currentResponsePattern):match(Fk:cloneCard(name))
      end) > 0
    end,
    on_lose = function (self, player, is_death)
      player.room:setPlayerMark(player, "@@zzz__zhiyuan_readying", 0)
      player:setSkillUseHistory(self.name, 0, Player.HistoryPhase)
      player:setSkillUseHistory(self.name, 0, Player.HistoryTurn)
      player:setSkillUseHistory(self.name, 0, Player.HistoryRound)
      player:setSkillUseHistory(self.name, 0, Player.HistoryGame)
    end,
  }
  local zzz__zhiyuan_reset = fk.CreateActiveSkill{
    name = "zzz__zhiyuan_reset",
    anim_type = "offensive",
    min_card_num = 0,
    max_card_num = 3,
    target_num = 0,
    interaction = function(self)
      local all_choices
      if Self:usedSkillTimes("zzz__zhiyuan", Player.HistoryGame) > 0 and Self:usedSkillTimes("zzz__zhiyuan", Player.HistoryRound) == 0 then
        all_choices = {"zhiyuan_resett", "zhiyuan_check2"}
      elseif Self:usedSkillTimes("zzz__zhiyuan", Player.HistoryGame) == 0 then
        all_choices = {"zhiyuan_check1"}
      else
        all_choices = {"zhiyuan_check2"}
      end
      return UI.ComboBox {choices = all_choices}
    end,
    card_filter = function(self, to_select, selected)
      if self.interaction.data == "zhiyuan_resett" then
        if Self:getMark("@@zzz__zhiyuan-free") > 0 then
          return true --#selected == 0
        else
          return #selected < 3 and not Self:prohibitDiscard(Fk:getCardById(to_select))
        end
      else
      return false
      end
    end,
    target_filter = Util.FalseFunc,
    on_use = function(self, room, effect)
      local player = room:getPlayerById(effect.from)
      if self.interaction.data == "zhiyuan_resett" then
        if #effect.cards > 0 then
          room:throwCard(effect.cards, "zzz__zhiyuan", player, player)
        end
        player:setSkillUseHistory("zzz__zhiyuan", 0, Player.HistoryGame)
        player:setSkillUseHistory("zzz__zhiyuan", 0, Player.HistoryRound)
        room:setPlayerMark(player, "@@zzz__zhiyuan_readying", 0)
        room:setPlayerMark(player, "@@zzz__zhiyuan-free", 0)
      end
    end,
    feasible = function (self, selected, selected_cards)
      return self.interaction.data ~= "zhiyuan_check1" and self.interaction.data ~= "zhiyuan_check2"
      and ((self.interaction.data == "zhiyuan_resett" and ((Self:getMark("@@zzz__zhiyuan-free") == 0 and #selected_cards == 3) 
      or (Self:getMark("@@zzz__zhiyuan-free") > 0 and #selected_cards == 0))))
    end,
  }
  local zzz__zhiyuan_trigger = fk.CreateTriggerSkill{
    name = "#zzz__zhiyuan_trigger",
    mute = true,
    anim_type = "drawcard",
    events = { fk.CardUseFinished },
    can_trigger = function(self, event, target, player, data)
      return target == player and data.card and data.card.skillName == "zzz__zhiyuan" and type(data.tos) == "table"
    end,
    on_cost = Util.TrueFunc,
    on_use = function(self, event, target, player, data)
      local targets = table.filter(TargetGroup:getRealTargets(data.tos), function (id)
        return not player.room:getPlayerById(id).dead
      end)
      local handless = {}
      local hpless = {}
      for _, id in ipairs(targets) do
        if table.every(targets, function(p) return player.room:getPlayerById(id):getHandcardNum() <= player.room:getPlayerById(p):getHandcardNum() end) then
          table.insertIfNeed(handless, id)
          player.room:setPlayerMark(player.room:getPlayerById(id), "@@zzz__zhiyuan-handless", 1)
        end
        if table.every(targets, function(p) return player.room:getPlayerById(id).hp <= player.room:getPlayerById(p).hp end) then
          table.insertIfNeed(hpless, id)
          player.room:setPlayerMark(player.room:getPlayerById(id), "@@zzz__zhiyuan-hpless", 1)
        end
      end
      local choices = {}
      if #handless > 0 then table.insert(choices, "zzz__zhiyuan_getcard") end
      if #hpless > 0 then table.insert(choices, "zzz__zhiyuan_gethp") end
      if #choices > 1 then table.insert(choices, "zzz__zhiyuan_backwater") end
      table.insert(choices, "cancel")
      local choice = player.room:askForChoice(player, choices, "zzz__zhiyuan", "#zzz__zhiyuan_trigger-choice")
      for _, p in ipairs(player.room.alive_players) do
        player.room:setPlayerMark(p, "@@zzz__zhiyuan-handless", 0)
        player.room:setPlayerMark(p, "@@zzz__zhiyuan-hpless", 0)
      end
      if choice == "zzz__zhiyuan_backwater" then
        local skills = table.map(table.filter(player.player_skills, function (s)
          return s:isPlayerSkill(player) and s.visible
        end), Util.NameMapper)
        if #skills > 0 then
          local skill = player.room:askForChoice(player, skills, "zzz__zhiyuan", "#zzz__zhiyuan_trigger-lose")
          player.room:handleAddLoseSkills(player, "-"..skill)
        end
      end
      if choice ~= "zzz__zhiyuan_gethp" and choice ~= "cancel" then
        for _, id in ipairs(handless) do
          if not player.room:getPlayerById(id).dead then
            local cards = player.room:getCardsFromPileByRule(".|.|.|.|.|equip", 1)
            if #cards > 0 then
              player.room:moveCards({
                ids = cards,
                to = id,
                toArea = Card.PlayerHand,
                moveReason = fk.ReasonPrey,
                proposer = player.id,
                skillName = "zzz__zhiyuan",
              })
            end
          end
        end
      end
      if choice ~= "zzz__zhiyuan_getcard" and choice ~= "cancel" then
        for _, id in ipairs(hpless) do
          if not player.room:getPlayerById(id).dead and player.room:getPlayerById(id):isWounded() then
            player.room:recover{
              who = player.room:getPlayerById(id),
              num = 1,
              recoverBy = player,
              skillName = self.name,
            }
          end
        end
      end
    end,

    refresh_events = {fk.AfterDrawPileShuffle},
    can_refresh = function(self, event, target, player, data)
      return player:getMark("@@zzz__zhiyuan_readying") > 0
    end,
    on_refresh = function(self, event, target, player, data)
      local room = player.room
        room:setPlayerMark(player, "@@zzz__zhiyuan_readying", 0)
        player:setSkillUseHistory("zzz__zhiyuan", 0, Player.HistoryGame)
        player:setSkillUseHistory("zzz__zhiyuan", 0, Player.HistoryRound)
    end,
  }
  local zzz__suyan = fk.CreateTriggerSkill{
    name = "zzz__suyan",
    anim_type = "offensive",
    events = {fk.CardUsing},
    can_trigger = function(self, event, target, player, data)
      return target == player and player:hasSkill(self) and
      data.extra_data and data.extra_data.combo_skill and data.extra_data.combo_skill[self.name]
    end,
    on_cost = function (self, event, target, player, data)
    local room = player.room
      if player:getMark("@@zzz__suyan-force") > 0 then
        room:setPlayerMark(player, "@zzz__suyan", 0)
        return true
      else
      local invoke = player.room:askForSkillInvoke(player, self.name, nil)
        if invoke then
          room:setPlayerMark(player, "@zzz__suyan", 0)
          return true
        else
          room:setPlayerMark(player, "@zzz__suyan", 0)
        end
      end
    end,
    on_use = function (self, event, target, player, data)
      local tars = {player}
      local force = false
      if player:getMark("@@zzz__suyan-force") > 0 then
        force = true
        player.room:setPlayerMark(player, "@@zzz__suyan-force", 0)
      end
      if type(data.tos) == "table" then
        for _, id in ipairs(TargetGroup:getRealTargets(data.tos)) do
          table.insertIfNeed(tars, player.room:getPlayerById(id))
        end
      end
      local index = ZZZstartCommand(player, self.name)
      local tos = {}
      for _, pid in ipairs(tars) do
        if not pid.dead then
          if force then
            ZZZdoCommand(pid, self.name, index, player, true)
          elseif not force then
            if not ZZZdoCommand(pid, self.name, index, player) then
              table.insert(tos, pid)
            end
          end
        end
      end
      for _, pid in ipairs(tos) do
        if not pid.dead then
          if pid:isNude() then
            player.room:addPlayerMark(pid, "@@zzz__suyan_chi", 1)
          else
            local cards = player.room:askForCardsChosen(player, pid, 1, 1, "he", self.name, "#zzz__suyan-show::"..pid.id)
            pid:showCards(cards)
            local result, str = {}, ""
            str = Fk:translate(":"..Fk:getCardById(cards[1]).name, "zh_CN")
            if string.find(str, "体力") then
              table.insert(result, "@@zzz__suyan_chi")
            end
            if string.find(str, "武器") then
              table.insert(result, "@@zzz__suyan_zhang")
            end
            if string.find(str, "打出") then
              table.insert(result, "@@zzz__suyan_tu")
            end
            if string.find(str, "距离") then
              table.insert(result, "@@zzz__suyan_liu")
            end
            if #result == 0 then
              table.insert(result, "@zzz__suyan_si")
            end
            for _, mark in ipairs(result) do
              player.room:addPlayerMark(pid, mark, 1)
            end
          end
        end
      end
    end,

    refresh_events = {fk.AfterCardUseDeclared},
    can_refresh = function (self, event, target, player, data)
      return target == player and player:hasSkill(self, true)
    end,
    on_refresh = function (self, event, target, player, data)
      local room = player.room
      room:addTableMark(player, "@zzz__suyan", data.card:getColorString())
      if #player:getTableMark("@zzz__suyan") == 2 then
        local mark = player:getTableMark("@zzz__suyan")
        if mark[1] ~= mark[2] then
          data.extra_data = data.extra_data or {}
          data.extra_data.combo_skill = data.extra_data.combo_skill or {}
          data.extra_data.combo_skill[self.name] = true
          return
        end
      end
      if data.card.type == Card.TypeEquip or (data.card.type == Card.TypeTrick and not data.card:isCommonTrick()) then
        room:setPlayerMark(player, "@zzz__suyan", {data.card:getColorString()})
      else
        room:setPlayerMark(player, "@zzz__suyan", 0)
      end
    end,

    on_lose = function (self, player, is_death)
      player.room:setPlayerMark(player, "@zzz__suyan", 0)
    end,
  }

  local zzz__suyan_delay = fk.CreateTriggerSkill{
    name = "#zzz__suyan_delay",
    mute = true,
    events = {fk.FinishJudge, fk.Damaged, fk.TargetConfirmed, fk.AfterCardsMove, fk.EventPhaseStart, fk.TurnEnd},
    can_trigger = function(self, event, target, player, data)
      if player.dead then return false end
      if event == fk.Damaged then
        return target == player and player:getMark("@@zzz__suyan_chi") > 0
      elseif event == fk.TargetConfirmed then
        return target == player and data.card.trueName == "slash" and player:getMark("@@zzz__suyan_zhang") > 0
      elseif event == fk.AfterCardsMove and player:getMark("@@zzz__suyan_tu") > 0 and not player:isKongcheng() then
        for _, move in ipairs(data) do
          if move.skillName ~= "zzz__suyan" and move.from == player.id then
            for _, info in ipairs(move.moveInfo) do
              if info.fromArea == Card.PlayerHand then
                return true
              end
            end
          end
        end
      elseif event == fk.EventPhaseStart then
        return target == player and player:getMark("@@zzz__suyan_liu") > 0 and player.phase == Player.Finish
      elseif event == fk.TurnEnd then
        return target == player and player:getMark("@zzz__suyan_si") > #player.room.alive_players
      end
    end,
    on_cost = Util.TrueFunc,
    on_use = function(self, event, target, player, data)
      local room = player.room
      if event == fk.Damaged then
        room:loseHp(player, data.damage, "zzz__suyan")
      elseif event == fk.TargetConfirmed then
        data.disresponsive = true
      elseif event == fk.AfterCardsMove then
        local cards = table.filter(player.player_cards[Player.Hand], function (id)
          return not player:prohibitDiscard(Fk:getCardById(id))
        end)
        if #cards > 0 then
          room:throwCard(table.random(cards, 1), "zzz__suyan", player, player)
        end
      elseif event == fk.EventPhaseStart then
        player:turnOver()
      elseif event == fk.TurnEnd then
        room:killPlayer({who = player.id})
      end
    end,
  }
  local zzz__suyan_maxcards = fk.CreateMaxCardsSkill {
    name = "#zzz__suyan_maxcards",
    correct_func = function(self, player)
      return -player:getMark("@zzz__suyan_si")
    end,
  }

  --神裁标记检测的函数，实际上就是耦扶摇/逐云阁出现的各种神裁标记
  --顺序：笞，徙（徒），杖，流，死，总数
  local function ZZZGodSentenceMarkCheck(player)
    local chi, xi, zhang, liu, si, sum = 0, 0, 0, 0, 0, 0
    chi = chi + player:getMark("@@shencai_chi") + player:getMark("@@hanqing__qielv_chi") + player:getMark("@[desc]shencai1chi") + player:getMark("@@zzz__suyan_chi")
    xi = xi + player:getMark("@@shencai_tu") + player:getMark("@@hanqing__qielv_xi") + player:getMark("@[desc]shencai1tu") + player:getMark("@@zzz__suyan_tu")
    zhang = zhang + player:getMark("@@shencai_zhang") + player:getMark("@@hanqing__qielv_zhang") + player:getMark("@[desc]shencai1zhang") + player:getMark("@@zzz__suyan_zhang")
    liu = liu + player:getMark("@@shencai_liu") + player:getMark("@@hanqing__qielv_liu") + player:getMark("@[desc]shencai1liu") + player:getMark("@@zzz__suyan_liu")
    si = si + player:getMark("@shencai_si") + player:getMark("@hanqing__qielv_si") + player:getMark("@[desc]shencai1si") + player:getMark("@zzz__suyan_si")
    sum = sum + (chi > 0 and 1 or 0) + (xi > 0 and 1 or 0) + (zhang > 0 and 1 or 0) + (liu > 0 and 1 or 0) + si
    return {chi, xi, zhang, liu, si, sum}
  end

  local zzz__huizheng = fk.CreateActiveSkill{
    name = "zzz__huizheng",
    prompt = "#zzz__huizheng",
    card_num = 0,
    min_target_num = 1,
    max_target_num = 2,
    card_filter = Util.FalseFunc,
    target_filter = function(self, to_select, selected)
      return #selected < 2 and ZZZGodSentenceMarkCheck(Fk:currentRoom():getPlayerById(to_select))[6] > 0
    end,
    on_use = function(self, room, effect)
      local player = room:getPlayerById(effect.from)
      local num = 0
      for _, p in ipairs(effect.tos) do
        if num == 2 then break end
        local pid = room:getPlayerById(p)
        local choice = {}
        if ZZZGodSentenceMarkCheck(pid)[1] > 0 then
          table.insert(choice, "zzz__huizheng_chi")
        end
        if ZZZGodSentenceMarkCheck(pid)[2] > 0 then
          table.insert(choice, "zzz__huizheng_xi")
        end
        if ZZZGodSentenceMarkCheck(pid)[3] > 0 then
          table.insert(choice, "zzz__huizheng_zhang")
        end
        if ZZZGodSentenceMarkCheck(pid)[4] > 0 then
          table.insert(choice, "zzz__huizheng_liu")
        end
        if ZZZGodSentenceMarkCheck(pid)[5] >= 1 then
          table.insert(choice, "zzz__huizheng_si1")
        end
        if ZZZGodSentenceMarkCheck(pid)[5] > 1 then
          table.insert(choice, "zzz__huizheng_si2")
        end
        if #choice > 0 then
          local n = #effect.tos == 1 and 2 or 1
          local m = 2 - num
          local tolose = room:askForChoices(player, choice, n, m, self.name, "#zzz__huizheng-lose::"..p, false)
          if table.contains(tolose,"zzz__huizheng_chi") then
            room:setPlayerMark(pid, "@@shencai_chi", 0)
            room:setPlayerMark(pid, "@@hanqing__qielv_chi", 0)
            room:setPlayerMark(pid, "@[desc]shencai1chi", 0)
            room:setPlayerMark(pid, "@@zzz__suyan_chi", 0)
          end
          if table.contains(tolose,"zzz__huizheng_xi") then
            room:setPlayerMark(pid, "@@shencai_tu", 0)
            room:setPlayerMark(pid, "@@hanqing__qielv_xi", 0)
            room:setPlayerMark(pid, "@[desc]shencai1tu", 0)
            room:setPlayerMark(pid, "@@zzz__suyan_tu", 0)
          end
          if table.contains(tolose,"zzz__huizheng_zhang") then
            room:setPlayerMark(pid, "@@shencai_zhang", 0)
            room:setPlayerMark(pid, "@@hanqing__qielv_zhang", 0)
            room:setPlayerMark(pid, "@[desc]shencai1zhang", 0)
            room:setPlayerMark(pid, "@@zzz__suyan_zhang", 0)
          end
          if table.contains(tolose,"zzz__huizheng_liu") then
            room:setPlayerMark(pid, "@@shencai_liu", 0)
            room:setPlayerMark(pid, "@@hanqing__qielv_liu", 0)
            room:setPlayerMark(pid, "@[desc]shencai1liu", 0)
            room:setPlayerMark(pid, "@@zzz__suyan_liu", 0)
          end
          if table.contains(tolose,"zzz__huizheng_si1") then
            local check = true
            if pid:getMark("@shencai_si") > 0 and check then
              room:removePlayerMark(pid, "@shencai_si", 1)
              check = false
            elseif pid:getMark("@hanqing__qielv_si") > 0 and check then
              room:removePlayerMark(pid, "@hanqing__qielv_si", 1)
              check = false
            elseif pid:getMark("@[desc]shencai1si") > 0 and check then
              room:removePlayerMark(pid, "@[desc]shencai1si", 1)
              check = false
            elseif pid:getMark("@zzz__suyan_si") > 0 and check then
              room:removePlayerMark(pid, "@zzz__suyan_si", 1)
              check = false
            end
          end
          if table.contains(tolose,"zzz__huizheng_si2") then
            local check = true
            if pid:getMark("@shencai_si") > 0 and check then
              room:removePlayerMark(pid, "@shencai_si", 1)
              check = false
            elseif pid:getMark("@hanqing__qielv_si") > 0 and check then
              room:removePlayerMark(pid, "@hanqing__qielv_si", 1)
              check = false
            elseif pid:getMark("@[desc]shencai1si") > 0 and check then
              room:removePlayerMark(pid, "@[desc]shencai1si", 1)
              check = false
            elseif pid:getMark("@zzz__suyan_si") > 0 and check then
              room:removePlayerMark(pid, "@zzz__suyan_si", 1)
              check = false
            end
          end
          num = num + #tolose
        end
      end
      local tochange = room:askForChoice(player, {"zzz__zhiyuan-free", "zzz__suyan-force"}, self.name, "#zzz__huizheng-renew")
      if tochange == "zzz__zhiyuan-free" then
        room:setPlayerMark(player, "@@zzz__zhiyuan-free", 1)
      elseif tochange == "zzz__suyan-force" then
        room:setPlayerMark(player, "@@zzz__suyan-force", 1)
      end
    end,
    feasible = function (self, selected, selected_cards)
      local x = 0
      for _, i in ipairs (selected) do
        x = x + ZZZGodSentenceMarkCheck(Fk:currentRoom():getPlayerById(i))[6]
      end
      return x >= 2
    end,
  }
  local zzz__huizheng_trigger = fk.CreateTriggerSkill{
    name = "#zzz__huizheng_trigger",
    anim_type = "masochism",
    events = {fk.Damaged},
    main_skill = zzz__huizheng,
    can_trigger = function(self, event, target, player, data)
      return target == player and player:hasSkill(self)
    end,
    on_cost = function(self, event, target, player, data)
      if player.room:askForUseActiveSkill(player, "zzz__huizheng", "#zzz__huizheng", true) then
        return true
      end
    end,
  }
  zzz__zhiyuan:addRelatedSkill(zzz__zhiyuan_reset)
  zzz__zhiyuan:addRelatedSkill(zzz__zhiyuan_trigger)
  zzz__suyan:addRelatedSkill(zzz__suyan_delay)
  zzz__suyan:addRelatedSkill(zzz__suyan_maxcards)
  zzz__huizheng:addRelatedSkill(zzz__huizheng_trigger)
  ZhuYuan:addSkill(zzz__zhiyuan)
  ZhuYuan:addSkill(zzz__suyan)
  ZhuYuan:addSkill(zzz__huizheng)

  Fk:loadTranslationTable{
    ["ysch4__ZhuYuan"] = "朱鸢",
    ["#ysch4__ZhuYuan"] = "稽司恍绻",
    ["cv:ysch4__ZhuYuan"] = "Mace",
    ["illustrator:ysch4__ZhuYuan"] = "镜丶GORK",
    ["designer:ysch4__ZhuYuan"] = "幽蝶化烬",

    ["zzz__zhiyuan"] = "执援",
    [":zzz__zhiyuan"] = "蓄势技，你可以视为使用即时牌，然后可以选择一项：手牌最少的目标获得一张装备牌；体力最少的目标回复1点体力；背水：失去一个技能。",
    ["zzz__suyan"] = "肃晏",
    [":zzz__suyan"] = "连招技（延时牌+与前者异色牌），你可以对你与目标角色发起“军令”，你展示拒绝执行者各一张牌，令其获得对应“神裁”标记(无牌则获得“笞”)。",
    ["zzz__huizheng"] = "麾整",
    [":zzz__huizheng"] = "出牌阶段，或你受到伤害后，你可以移去场上两个“神裁”标记并选择一项：下次“执援”主动重置无须弃牌；或令下次“肃晏”的发动与军令均强制。<br>"..
    "<a href='ysch4__ZhuYuan_ifstory_href'>这个朱鸢处于名为“凫遥”的平行宇宙中。</a>",
    ["ysch4__ZhuYuan_ifstory_href"] = "朱鸢在得知铃与哲隐瞒自己绳匠身份长达一个版本后，顿觉急火攻心，决心成为超越虚狩的强者，洗刷背叛与隐瞒的耻辱。"..
    "据说，朱鸢买好离开的船票后，曾想给在家的亲人发送短信告辞，但无意间看到自己入职时后拍摄的空洞照片，感叹“昔年空洞，今看湮没，洞犹如此，人何以堪”后径直离开。<br>"..
    "在一个头顶复眼，手提酒壶与青色利剑的世外高人介绍下，朱鸢前往了一个名叫“凫遥”的习武之地。在这里，善良的人们接纳了朱鸢，为她更换了一把称手的弑君武器。"..
    "又将朱鸢引荐到了代号284的远古战士门下，修习名为《亦书成花》的功法，在目睹神韩信斩杀相柳大蛇的场面后领悟到武学之要，当夜便打通了自己的任督二脉，连袭十三郡，"..
    "威震“凫遥”。<br>然而，自认抵达武学顶峰的朱鸢却在兼资武武的高人手下第一次体会到了死亡的感受，意识到“武功再高，一下撂倒”，于是寻求致命武力，期间也曾有新艾利都的"..
    "故交找到朱鸢，希望朱鸢回去与家人团聚，与两位录像店店长重修于好，被朱鸢以“既不能版本答案，不足复战阳斗阴，（以）骸未灭，家何为！”回绝。<br>"..
    "“凫遥”世外桃源的现状因为朱鸢的出逃逐渐被新艾利都的高层知晓，忌恨于此的酒囊饭袋们招募鹰犬准备进犯“凫遥”所在的“馨月沙”星球，将星球的人们强制回迁到新艾利都爆金币。<br>"..
    "短短三天，“馨月沙”上仅剩“凫遥”在内的几个城邦苦苦支撑，被征服的城邦被神张飞为首的一将成名阴间势力洗劫一空，而星球上的腥风血雨此刻却被银河间人造的困境与反思热点覆盖。"..
    "朱鸢知道祸端与自己有关，应该出手终结乱局，便不顾师傅反对，留下了一封<a href='yishu_href'>遗书</a>，毅然前往对抗阴间势力的前端，要以毕生所学夺下死亡的权柄。"..
    "<br>战局异常惨烈，虽然朱鸢已经获得了比在绝区零当前版本中更强的数值，但是神张飞阎王点卯，依靠着每次出牌发五个死标记不断强制击杀抵抗的战士们，就连兼资武武的高人也因"..
    "没有随机到神张飞提前把自己送走了。神裁的阴影即将照射到朱鸢之时，朱鸢想起两位录像店店长冒着被治安局逮捕的风险为自己指出生路的过往，理解了店长，大喊“店长助我！”。"..
    "<br>被朱鸢强烈的愿望感召，店长与堕化店长将商店中的纳塔武器牌交给朱鸢，挡下了神张飞的两轮神裁。大黄蜂用尽最后的韧之意，让朱鸢等到自己回合重置蓄势技，也把自己崩死了。".. 
    "<br>神张飞的死之标记已然指向朱鸢，朱鸢用蓄势技开出了最后一个决斗，将神张飞打到一血，准备成为炮灰之时，一个“服务器已关闭”的弹窗使整片战场归于寂静。黑暗冥迷中，朱鸢熟悉的"..
    "声音响起“你不会真以为喊店长喊出来的只有店长和堕化店长吧？我们Random Play也要面子的好吧！”接着，泪水瞬间打湿朱鸢的眼眶————朱鸢看见“凫遥”的人们在铃和哲的指挥下转移到虚空。"..
    "<br>“啪”，光芒照射到战场上，阴间势力们对着空旷的敌方阵营面面相觑，再抬头，朱鸢漂浮在空中，说出了一句话，然后一个响指，场上所有的阴间灰飞烟灭，神张飞将丈八死死插入土地，"..
    "留下一句“尔等，欲复斩我头乎？”。神李悝，孙峻，拉撒路和朱鸢联手瓜分了神张飞残余的标记力量，净化了“凫遥”被污染的土地，人们欢呼这四个人的名字，迎接崭新的生活。"..
    "<br>自此，朱鸢掌握了“凫遥”的终极法则，第一次拥有了新艾利都中“虚狩”的力量。她击败天外来客的传奇注定被说书人和吟游诗人传唱四方，届时，所有人都会想起那天"..
    "朱鸢斜着眼睛瞥视“凫遥”诸天神魔时的那句警世名言：我现在就停止续费！(◣_◢)",
    ["yishu_href"] = "感觉星见雅跟我差不多，表面上懒散随和，跟众人打成一片，但实际上走一步算十步，心思缜密远超同龄人，我从来不缺雷霆手段也不缺菩萨心肠, 我心中有佛也有魔, "..
    "但我把魔深深的封印起来了, 只剩下佛了, 我本想以菩萨心肠面对所有人, 可是有些人非要我把心中的魔解除封印, 那我想问问你们, 当你们面对一个真正的魔现世, 你们还镇的住吗？呵呵。",

    ["#zzz__zhiyuan-viewas"] = "执援：选择你需要使用的牌名，视为使用之！",
    ["#zzz__zhiyuan_trigger-invoke"] = "执援：是否执行后续？",
    ["@@zzz__zhiyuan_readying"] = "执援 蓄势中",
    ["@@zzz__zhiyuan-free"] = "执援 直接重置",
    ["@@zzz__zhiyuan-handless"] = "手牌最少目标",
    ["@@zzz__zhiyuan-hpless"] = "体力最少目标",
    ["zzz__zhiyuan_getcard"] = "手牌最少的目标获得一张装备牌",
    ["zzz__zhiyuan_gethp"] = "体力最少的目标回复1点体力",
    ["zzz__zhiyuan_backwater"] = "背水：失去一个技能",
    ["#zzz__zhiyuan_trigger-choice"] = "执援：您选择执行后续，请选择一项！",
    ["#zzz__zhiyuan_trigger-lose"] = "执援：您执行背水，请失去一个技能。",
    ["zzz__zhiyuan_reset"] = "执援*",
    [":zzz__zhiyuan_reset"] = "出牌阶段，你可以重置已发动的“执援”（没有直接重置标记则须弃三张牌重置）或查看“执援”可用状态！",
    ["#zzz__zhiyuan_trigger"] = "执援",
    ["zhiyuan_check1"] = "执援：可用",
    ["zhiyuan_check2"] = "执援：不可用",
    ["zhiyuan_resett"] = "执援：重置",
    ["@zzz__suyan"] = "肃晏",
    ["#zzz__suyan-show"] = "肃晏：展示 %dest 一张牌",
    ["@@zzz__suyan-force"] = "肃晏 强制",
    ["#zzz__suyan_delay"] = "肃晏",
    ["@@zzz__suyan"] = "肃晏",
    ["@@zzz__suyan_chi"] = "笞",
    ["@@zzz__suyan_zhang"] = "杖",
    ["@@zzz__suyan_tu"] = "徒",
    ["@@zzz__suyan_liu"] = "流",
    ["@zzz__suyan_si"] = "死",
    ["zzz__huizheng_chi"] = "笞",
    ["zzz__huizheng_zhang"] = "杖",
    ["zzz__huizheng_xi"] = "徒",
    ["zzz__huizheng_liu"] = "流",
    ["zzz__huizheng_si1"] = "死",
    ["zzz__huizheng_si2"] = "死",
    ["#zzz__huizheng_trigger"] = "麾整",
    ["#zzz__huizheng"] = "麾整：你可移去场上两个神裁标记以强化你的一个技能！",
    ["#zzz__huizheng-lose"] = "麾整：移除 %dest 的神裁标记！（可选项为2减本次麾整已移除标记数！死标记单独计数！）",
    ["zzz__zhiyuan-free"] = "下次“执援”主动重置无须弃牌",
    ["zzz__suyan-force"] = "下次“肃晏”的发动与军令均强制",
    ["#zzz__huizheng-renew"] = "麾整：请选择一项！",

    ["$zzz__zhiyuan"] = "兔兔伯爵，出击！",
    ["$zzz__suyan"] = "交给我吧！",
    ["$zzz__huizheng"] = "交给我吧！",
    ["~ysch4__ZhuYuan"] = " ",
  }

  Fk:loadTranslationTable{
    ["ysch4__Rina"] = "丽娜",
    ["#ysch4__Rina"] = "移拾莼桦",
    ["cv:ysch4__Rina"] = "张若瑜",
    ["illustrator:ysch4__Rina"] = "羽々斬",
    ["designer:ysch4__Rina"] = "幽蝶化烬",
  }

  --让锡躯最后加载，强行规定技能顺序
  for loop = 0, 110, 1 do  --110个应该够用，为啥？因为零号加十一呀
    local zzz__xiqu = fk.CreateActiveSkill{
      name = loop == 0 and "zzz__xiqu" or "zzz"..loop.."__xiqu",
      mute = true,
      frequency = Skill.Limited,
      card_num = 0,
      target_num = 1,
      times = function (self)
        return 1 - Self:usedSkillTimes(self.name, Player.HistoryGame)
      end,
      can_use = function(self, player)
        return player:usedSkillTimes(self.name, Player.HistoryGame) == 0
      end,
      card_filter = Util.FalseFunc,
      target_filter = function(self, to_select, selected, selected_cards)
        return #selected == 0 and not Fk:currentRoom():getPlayerById(to_select):isKongcheng()
      end,
      on_use = function(self, room, effect)
        local player = room:getPlayerById(effect.from)
        local target = room:getPlayerById(effect.tos[1])
        player:broadcastSkillInvoke("zzz__xiqu")
        room:notifySkillInvoked(player, "zzz__xiqu", "offensive")
        local id = room:askForCardChosen(player, target, "h", self.name)
        player:showCards(id)
        if table.contains(target:getCardIds("h"), id) and not target.dead then
          local choices = {"zzz__xiqu__seal", "zzz__xiqu__recast"}
          local choice = room:askForChoice(target, choices, self.name, "#zzz__xiqu-skill")
          if choice == "zzz__xiqu__recast" then
          room:recastCard({id}, target, self.name)
          if not player.dead then
          local get = {}
          local names = {"slash", "fire__slash", "thunder__slash", "ice__slash"}
            if not Fk.all_card_types["ice__slash"] then --军争一般都开吧？
              table.removeOne(names, "ice__slash")
            end
            if #names > 0 then
              table.insert(get, room:printCard(table.random(names, 1)[1], math.random(5), math.random(0, 14)).id)
              room:obtainCard(player, get, true, fk.ReasonJustMove, player.id, self.name, MarkEnum.DestructIntoDiscard)
            end
          end
        elseif choice == "zzz__xiqu__seal" then
          room:addTableMark(target, self.name, {effect.from, id})
          room:setCardMark(Fk:getCardById(id), "@@zzz__xiqu", effect.from)
          end
        end
      end,
    }
    if loop > 0 then
      --zzz__xiqu:addRelatedSkill(zzz__xiqu_delay)
      --:addRelatedSkill(zzz__xiqu_prohibit)
      Fk:addSkill(zzz__xiqu)
    else
      zzz__xiqu:addRelatedSkill(zzz__xiqu_delay)
      zzz__xiqu:addRelatedSkill(zzz__xiqu_prohibit)
      SilverAnby:addRelatedSkill(zzz__xiqu)
      SoldierEleven:addSkill(zzz__xiqu)
      Cuiji:addSkill(zzz__xiqu)
    end
    Fk:loadTranslationTable{
      ["zzz"..loop.."__xiqu"] = "锡躯",
      [":zzz"..loop.."__xiqu"] = "宗族技，限定技，出牌阶段，你可以展示一名角色的一张手牌，令其选择一项：此牌不可被没有“锡躯”的角色使用；重铸此牌，令你获得一张【杀】。",
    }
  end

  return extension 